Click to See Complete Forum and Search --> : Add 2 numbers


AndyK
October 4th, 1999, 12:44 AM
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...

Lothar Haensler
October 4th, 1999, 01:56 AM
text3.text = cint(text1.text) + cint(text2.text)

October 5th, 1999, 07:08 AM
Alternatively try this :
result = val(trim(text1.text)) + val(trim(text2.text))



---Siva----

October 5th, 1999, 07:30 AM
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.