PDA

Click to See Complete Forum and Search --> : String Variable to Double


nihho
Nov 22nd, 1999, 12:30 AM
Hello,
I have a little problem with conversion a string variable to double one.
Here is the code:

Private Sub Form_Click()
Dim a As Double
Dim b As Double
Dim c As Double
Dim d As String
a=2
b=3
d = Text1.Text
'Text1.Text="a+b"
'I type this when running the form
c = Val(d)
MsgBox c
'I want to get result 5, but it displays 0. 'What's wrong ???
End Sub

Please, help me to get rid of this !!!

jim
Nov 22nd, 1999, 02:07 AM
Private Sub Form_Click()
Dim a As Double
Dim b As Double
Dim c As Double
Dim d As String

a=2
b=3
d = Text1.Text

_____________________________________
' Cannot type name of variables in to textbox
' on form --- After this the string 'd' holds
' the value 'a+b' as a string, when the val
' function executes --- there is no valid ' integer in the variable so it returns 0.
' ' try typing '5' into your textbox...
__________________________________________

'Text1.Text="a+b"
'I type this when running the form
c = Val(d)
MsgBox c
'I want to get result 5, but it displays 0. 'What's wrong ???
End Sub