I have a simple ASP script I am trying to run. Forgive me if this is a real newbie question but I did some searches first and checked an ASP reference and it seems like I am doing everything right - but apparently not.
Heres the scenario:
A = 1 B = 2
Total = A + B
When it outputs the total, it outputs 12 rather than 3.
4:57 pm on Aug 12, 2003 (gmt 0)
In VBScript you will have to use the "cint" function to make numbers.
give those a try.
6:05 pm on Aug 12, 2003 (gmt 0)
Hmmmm. I add stuff together all the time in vb script without a cint(). I don't recall seeing the plus sign behave as a concatenation operator. Shmekkyl, are you using Jscript by chance?
The ampersand (&) is the concatenation operator in ASP.
6:39 pm on Aug 12, 2003 (gmt 0)
asp can use either jscript or vbscript. The ampersand is the concatenation operator for vbscript, the plus symbol is the concatenation operator for jscript. It sounds like you are inadvertently executing jscript with your asp rather than vbscript.
6:41 pm on Aug 12, 2003 (gmt 0)
shmekkyl, any time you set a variable equal to request("anything"), you're defining it as a string. The '+' operator adds two variables together and adding two strings together is concatenation. Did you try txbakers suggestion to use cInt()? That oughta do it..
dim TotalColors TotalColors = cint(FrontColors) + cint(BackColors)
might work for you. give that a try.
9:03 pm on Aug 12, 2003 (gmt 0)
That did it. I thought it uploaded but it didnt. Thanks for all your help.
9:10 pm on Aug 12, 2003 (gmt 0)
Yeah - that was one of the trickiest things to get used to - that ALL web form data are strings. Even the numbers and dates. Once they get put into the request object, you need to manipulate them to make them the type you need.
11:05 pm on Aug 12, 2003 (gmt 0)
its weird that it lets me multiply and divide without doing anything special.
11:08 pm on Aug 12, 2003 (gmt 0)
Thats because those operators cannot be overloaded for strings, so it casts. try multiplying text :)