Results 1 to 2 of 2

Thread: String Variable to Double

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 1999
    Posts
    4

    Post

    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 !!!

  2. #2
    Junior Member
    Join Date
    Jun 1999
    Location
    Papillion, NE, USA
    Posts
    21

    Post

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width