Results 1 to 4 of 4

Thread: Easy Question!!!

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2000
    Posts
    29

    Arrow

    I have a easy problem that i can't figure out, here is the code

    Private Sub Command1_Click()

    a = Text1.Text
    b = Text2.Text
    c = Text3.Text

    d = a + b + c

    Text4.Text = d

    End Sub

    The problem is if you enter a number into TEXT1,TEXT2,and TEXT3, the result is not added together.
    Example: TEXT1 = 4
    TEXT2 = 5
    TEXT3 = 6

    The resultis 456, but i need it to do the addition??
    Any ideas??
    Altecjjf


  2. #2
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    That's because they're strings, you need to convert them to numbers.

    Code:
    Private Sub Command1_Click() 
    
    a = Text1.Text 
    b = Text2.Text 
    c = Text3.Text 
    
    d = int(a) + int(b) + int(c) 
    
    Text4.Text = d 
    
    End Sub
    Oetje
    [email protected]
    93606776
    Visual Basic 6, Windows 2000

    Never pet a burning dog

  3. #3
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    'Or
    Dim d As Integer
    d = Val(Text1) + Val(Text2) + Val(Text3)
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Jun 2000
    Posts
    29
    thanks, it worked

    altecjjf

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