all groups > sql server programming > february 2004 >
You're in the

sql server programming

group:

Help with vars.


Re: Help with vars. Anith Sen
2/29/2004 9:36:19 PM
sql server programming:
It seems like currently the variables strBalance and strLink are character
compatible datatypes and hence the operator '+' assumes the role of
concatenation instead of addition. So, to avoid this, you can convert the
values in the strBalance and strLink variable to numeric compatible
datatypes, perhaps using CInt, CDbl or whatever is relevant to your
application and then convert it back to string. Something along the lines
of:

....
SET PmtRecd = " & CStr(CDbl(strBalance) + CInt(strLink)) & " " &_
....

--
Anith

Help with vars. Aleks
2/29/2004 10:26:35 PM
Hi,

This might be an easy one, just cant find how to code it.
I have 2 variables which I want to add (strBalance and strLink) the values
could be: 500+300 = 800.

The problem is that my code is instead adding them like this: 500+300 =
500,300

Below is the code.

------------------------------------------------
For iLoop = 0 to iCount
strLink = Request(iLoop & ".Link")
strBalance = Request(iLoop & ".Balance")
strID = Request(iLoop & ".ID2")
strSQL = "UPDATE BillingLines SET PmtRecd = " & strBalance + strLink & " "
&_
" WHERE Id = " & strID
----------------------------------------------------------

How can I do the code so that it adds correctly ?

Appreciate any help !

Axi



AddThis Social Bookmark Button