1 Replies - 294 Views - Last Post: 25 January 2019 - 01:50 AM Rate Topic: -----

#1 knenok   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 25-January 19

calling procedure "inputbox" 4 times

Posted 25 January 2019 - 12:18 AM

supposed to find the average of 4 numbers using the inputbox procedure, it's not allowing me to go from string to double in the last line of code

i have:

[Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim FirstNumber As String
Dim SecondNumber As String
Dim ThirdNumber As String
Dim FourthNumber As String

FirstNumber = (InputBox("Please enter a number.", "Get number."))

SecondNumber = (InputBox("Please enter a number.", "Get number."))

ThirdNumber = (InputBox("Please enter a number.", "Get number."))

FourthNumber = (InputBox("Please enter a number.", "Get number."))





TextBox5.Text = (CDbl(((((InputBox("Please enter a number.", "Get number."))) + ((InputBox("Please enter a number.", "Get number.")))) + (((InputBox("Please enter a number.", "Get number."))) + ((InputBox("Please enter a number.", "Get number.")))))) / 4))

End Sub]

Is This A Good Question/Topic? 0
  • +

Replies To: calling procedure "inputbox" 4 times

#2 andrewsw   User is offline

  • Stealth IT
  • member icon

Reputation: 6735
  • View blog
  • Posts: 27,712
  • Joined: 12-December 12

Re: calling procedure "inputbox" 4 times

Posted 25 January 2019 - 01:50 AM

Erm, don't do that... you'll end up with 8 inputboxes, not 4.

You already have the values stored in FirstNumber, etc.. It is those values that you need to convert to numbers.



Please wrap your code in [ code ] tags when posting. Look around the edit box when you are typing, you'll soon discover how to add them. Or read the message directly in the edit box.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1