i have strA and strB
strA = 1
strB = 1
i try text1.text = strA + strB
but it doesn't work the result is 11 not 2 why?
Printable View
i have strA and strB
strA = 1
strB = 1
i try text1.text = strA + strB
but it doesn't work the result is 11 not 2 why?
Quote:
Originally Posted by vbcooler
Also, if you are going to be adding these together, they should be declared as integersVB Code:
Text1.Text = Val(strA) + Val(strB)Then, you wouldn't need to Val them.VB Code:
Dim intA As Integer Dim intB As Integer
THEY CAN'T BE DECLER AS AN INTEGER SINCE SOME OF THE NUMBERS COULD BEQuote:
Originally Posted by Hack
1.3
5.5
ETC..
Declare them as Long, single or double then
A Single or a Double would return decimals. A Long will round to an even number.Quote:
Originally Posted by Atheist
oh yes youre right :blush:Quote:
Originally Posted by Hack
Long will truncate to an integer, not round to an even number!
Right?
Wrong. If you have this statement
Long = Double + Double
The Double + Double would be rounded to the nearest integer.
Not all "Wrong"... ;)
Long does indeed round a number (I thought it truncated it :blush: ), but it doesn't necessarily round to an EVEN number (1.3 gets rounded to 1 - an ODD number).
Now I think we're straight!
:lol: Ok, I misspoke. Long doesn't round to an even number it rounds to a whole number (which is actually what I meant but not what I typed.)Quote:
Originally Posted by Set me As newtype
Quote:
Originally Posted by vbcooler
The '+' serves to join (concatenate) Strings. However, If you want to concatenate Strings, thenQuote:
..... the result is 11 not 2 why?[/
the appropriate operator is the '&' (ampersand), noting the '+' will do the same. Hence, you got '11' and not a mathematecal add equaling 2. :)