1. Junior Member
Join Date
Dec 1969
Posts
27

Instead of adding, it&#039;s concatenating. :<BR><BR>Values on form are<BR>0 or 5<BR>A_1 = Request.Form("A_1")<BR>A_2 = Request.Form("A_2")<BR>A_3 = Request.Form("A_3")<BR>A_4 = Request.Form("A_4")<BR>A_5 = Request.Form("A_5")<BR><BR>group1 = (A_1 + + A_2 + + A_3 + + A_4 + + A_5)<BR><BR>response.write group1 just pulls up 57537<BR><BR>instead of adding them together. :<BR><BR>This is a stupid problem that I&#039;m hoping someone has the answer to.<BR><BR><BR>-VB REF<BR>_<BR>If Then <BR>Both expressions are numeric Add. <BR>Both expressions are strings Concatenate. <BR>One expression is numeric and the other is a string Add. <BR><BR>If one or both expressions are Null expressions, result is Null. If both expressions are Empty, result is an Integer subtype. However, if only one expression is Empty, the other expression is returned unchanged as result. <BR>

2. Senior Member
Join Date
Dec 1969
Posts
10,852

## Example.

A_1 = Request.Form("A_1") <BR><BR>Should be<BR><BR>A_1 = CLng(Request.Form("A_1")) - (For integers)<BR><BR>or<BR><BR>A_1 = CDbl(Request.Form("A_1")) - (For non-integers)

3. Senior Member
Join Date
Dec 1969
Posts
3,921

## Val = Clng(Val1) + Clng(Val2)

.

4. Junior Member
Join Date
Dec 1969
Posts
27

## RE: Example.

I tried CInt<BR><BR>Son of a *****! I&#039;ve been doing this all day.<BR><BR>Thanks a lot.<BR>

5. Senior Member
Join Date
Dec 1969
Posts
96,118

## Good for you!

You found the relevant part of the docs!<BR><BR>The point is, of course, that Request.Form *ALWAYS* returns a STRING. Period. Always.<BR><BR>So you have to convert that to a number if you want addition to take place. The "safest" function to use for that is CDBL. It will handle numbers with decimal points, exponents, etc., etc. If you *know* that the numbers are always integers, then use CLNG.<BR><BR>THus:<BR><BR>A_1 = CDBL( Request.Form("A_1") )<BR>A_2 = CDBL( Request.Form("A_2") )<BR>A_3 = CDBL( Request.Form("A_3") )<BR>A_4 = CDBL( Request.Form("A_4") )<BR>A_5 = CDBL( Request.Form("A_5") )<BR><BR><BR>

6. Senior Member
Join Date
Dec 1969
Posts
10,852

## LOL...No problem. <eop>

.

7. Senior Member
Join Date
Dec 1969
Posts
2,049

group1 = (A_1 + A_2 + A_3 + A_4 + A_5) *1<BR><BR>This should add them together.<BR>I use the *1 to make sure it adds them.<BR><BR>I&#039;m not following the bottom part. -VB REF<BR>

8. Senior Member
Join Date
Dec 1969
Posts
10,852

Nope, (this is entirely conjecture, but if the order of operations is right) that *should* still concatenate them, them convert to numeric, and multiply that by one.<BR><BR><BR>I guess I should really test it bofore I post...But I&#039;ve been wrong before, and I won&#039;t hesitate to be wrong again. :-)

9. Senior Member
Join Date
Dec 1969
Posts
10,852

## Woo Hoo!

I was right!

10. Senior Member
Join Date
Dec 1969
Posts
96,118

## What you could do (UGH!)...

group1 = 0 - ( 0 - A_1 - A_2 - A_3 - A_4 - A_5)<BR><BR>[The 0&#039;s aren&#039;t really necessary, but they make it clearer, I thought.)

#### Posting Permissions

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