CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Add 2 numbers

  1. #1
    Join Date
    Aug 1999
    Location
    US, Florida
    Posts
    817

    Add 2 numbers

    I want to add whatever is in Text1.text and Text2.text
    well I tried to use text3.text = text1.text + text2.text but it shows me like if Text1 had 5 and text2 had 7 then it shows me 57 instead of 12
    How can I asign a + so that my program will think that + stands for "add", multiply (*) works perfect...


  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: Add 2 numbers

    text3.text = cint(text1.text) + cint(text2.text)


  3. #3
    Guest

    Re: Add 2 numbers

    Alternatively try this :
    result = val(trim(text1.text)) + val(trim(text2.text))



    ---Siva----


  4. #4
    Guest

    Re: Add 2 numbers

    U'r question is very basic, In visual basic '+' operator can be used for two purpose based on the values, if u give strings in both the sides, the operator will taken as a string concatenator. if u want to add two numbers u have to convert the string into number using the functions Cint or Val. Because the textbox will treat all values as a string only.


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

Featured