-
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...
-
Re: Add 2 numbers
text3.text = cint(text1.text) + cint(text2.text)
-
Re: Add 2 numbers
Alternatively try this :
result = val(trim(text1.text)) + val(trim(text2.text))
---Siva----
-
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.