1. Junior Member
Join Date
Dec 1969
Posts
1

When I pass three numbers from a form to my ASP page they are being concatenated instead of added.<BR><BR>I pass them into my ASP page like this:<BR><BR>s1 = Request.Form("s1")<BR>s2 = Request.Form("s2")<BR>s3 = Request.Form("s3")<BR><BR><BR>Let&#039;s say s1 = 56, s2 = 24, and s3 = 20.<BR><BR>I then perform this supposed addition:<BR><BR>probsum = s1 + s2 + s3<BR><BR>I would think after this that probsum would = 100. Instead, probsum = 562420, the concatenation of the three passed variables.<BR><BR>What am I doing wrong and how do I correct it?<BR><BR>Tks!<BR>

2. God
Senior Member
Join Date
Dec 1969
Posts
18,177

## Convert them to numbers.

s1 = CDbl(Request.Form("s1"))<BR>s2 = CDbl(Request.Form("s2"))<BR>s3 = CDbl(Request.Form("s3"))<BR><BR>You&#039;ll need to add error handling, just in the case that the Request.Form values aren&#039;t numbers.<BR>

3. Senior Member
Join Date
Dec 1969
Posts
2,334

## they are being treated as strings

convert them to Number. Use CNum or CInt.

4. God
Senior Member
Join Date
Dec 1969
Posts
18,177

## Cint() is Hell's spawn.

CDbl() is mucho better to use.<BR><BR>CInt() has a maximum of 32,767.<BR><BR>CInt() converts the numbers to WHOLE numbers (so you lose any decimals).

5. meg
Member
Join Date
Dec 1969
Posts
64

## RE: Convert them to numbers.

I have somehow same problem, can anyone tell me how to add error handling in case that Request.querystring values aren&#039;t numbers?

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•