Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP Data types 1

Status
Not open for further replies.

fischadler

Programmer
May 31, 2002
258
MT
How do I specify the data type for a variable?
In Visual Basic I do something like this:

Dim intQTY as Integer

But this does not seem to work in ASP. This is causing me problems because sometimes I try to make a numeric addition but end up having a string addition instead.

Thanks!
 
ASP is a "loosely typed" language - you cannot declare variables to be of one data type or another - they are all "variant".

a = 1
b = "2"

a + b = "12"

cInt(a) + cInt(b) = 3

cInt(a+b) = 12


You need to be mindful of the data thta is loaded into the variable. Use cInt(), cLng(), cSng(), cDbl() to make sure it is seen as numeric...

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top