I am picking up data from an html form. The fields
contain numbers. For some incredibly weird reason,
vbscript insists on concatenating the numbers so that 1,
2 and 6 add up to 126 instead of 9. I sure wish I could
use the old val function in VB to force it to do
addition. Below, I am using isnumeric to test for
numbers, rather than blanks in the fields.

if isnumeric(Request.Form("quant2"))then
quantity2=(Request.Form("quant2"))
else quantity2=0
end if

Clearly, isnumeric is not generating any errors, since
the numbers do show up--they just are not added together.

I also first tried:

if (request.form("quant3"))<>"" then
quantity3=(Request.Form("quant3"))
else quantity3=0
end if

I then add up the variables like:

quantot = quantity1 + quantity2 + quantity3

I also tried to use the conversion function for Cint and
Csng, which made no difference.

Re: can't add up numbers from form fields by Evertjan

Evertjan
Sat Aug 02 16:37:25 CDT 2003

Patricia wrote on 02 aug 2003 in microsoft.public.scripting.vbscript:

> I then add up the variables like:
>
> quantot = quantity1 + quantity2 + quantity3
>
> I also tried to use the conversion function for Cint and
> Csng, which made no difference.
>

quantot = 1*quantity1 + 1*quantity2 + 1*quantity3



--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Re: can't add up numbers from form fields by Patricia

Patricia
Sat Aug 02 17:12:23 CDT 2003

I did that, but get the same result. I also followed
another thread where the solution was to use conversion
functions, but I get an internal server error when I do
that. thanks anyway.


>-----Original Message-----
>Patricia wrote on 02 aug 2003 in
microsoft.public.scripting.vbscript:
>
>> I then add up the variables like:
>>
>> quantot = quantity1 + quantity2 + quantity3
>>
>> I also tried to use the conversion function for Cint
and
>> Csng, which made no difference.
>>
>
>quantot = 1*quantity1 + 1*quantity2 + 1*quantity3
>
>
>
>--
>Evertjan.
>The Netherlands.
>(Please change the x'es to dots in my emailaddress)
>.
>

Re: can't add up numbers from form fields by Chris

Chris
Sat Aug 02 17:57:09 CDT 2003

I don't want to sound daft here but the only possible result value for:

Dim pdblValue

pdblValue = CDbl(pvarValue1) + CDbl(pvarValue2) + CDbl(pvarValue3)

is a number or an error.

Try this test code to see what is output to the browser:

On Error Resume Next

'pvarValue1,2,3 are form the form fields.

Response.Write "Value1 = '" & pvarValue1 & "' IsNumeric returns " &
IsNumeric(pvarValue1)
Response.Write "Value2= '" & pvarValue1 & "' IsNumeric returns " &
IsNumeric(pvarValue1)
Response.Write "Value3 = '" & pvarValue1 & "' IsNumeric returns " &
IsNumeric(pvarValue1)

pdblValue = CDbl(pvarValue1) + CDbl(pvarValue2) + CDbl(pvarValue3)

If Err.Number > 0 Then
Response.Write "An error occurred during the addition." & vbCrLf & "[" &
Err.Number & "] " & Err.Description
Err.Clear
End If

Response.Write "Result = '" & pdblValue & "' IsNumeric returns " &
IsNumeric(pdblValue)

NB: The single quotes are just to see if there is extraneous padding or
extra characters in the form field values.

Chris.

"Patricia" <patricia@hitekdesigns.com> wrote in message
news:021901c35943$25e80770$a301280a@phx.gbl...
I did that, but get the same result. I also followed
another thread where the solution was to use conversion
functions, but I get an internal server error when I do
that. thanks anyway.


>-----Original Message-----
>Patricia wrote on 02 aug 2003 in
microsoft.public.scripting.vbscript:
>
>> I then add up the variables like:
>>
>> quantot = quantity1 + quantity2 + quantity3
>>
>> I also tried to use the conversion function for Cint
and
>> Csng, which made no difference.
>>
>
>quantot = 1*quantity1 + 1*quantity2 + 1*quantity3
>
>
>
>--
>Evertjan.
>The Netherlands.
>(Please change the x'es to dots in my emailaddress)
>.
>



Re: can't add up numbers from form fields by Pa

Pa
Sat Aug 02 19:40:52 CDT 2003

I got an internal server error (500) when I added your
code. I tried remarking some of it out, but finally had
to remove it. But--Guess what? When I used your syntax:


quantot = Csng(quantity1) + Csng(quantity2)+ Csng
(quantity3)

it works. Thanks a lot. I don't know why the on error
code doesn't work.

>-----Original Message-----
>I don't want to sound daft here but the only possible
result value for:
>
>Dim pdblValue
>
>pdblValue = CDbl(pvarValue1) + CDbl(pvarValue2) + CDbl
(pvarValue3)
>
>is a number or an error.
>
>Try this test code to see what is output to the browser:
>
>On Error Resume Next
>
>'pvarValue1,2,3 are form the form fields.
>
>Response.Write "Value1 = '" & pvarValue1 & "' IsNumeric
returns " &
>IsNumeric(pvarValue1)
>Response.Write "Value2= '" & pvarValue1 & "' IsNumeric
returns " &
>IsNumeric(pvarValue1)
>Response.Write "Value3 = '" & pvarValue1 & "' IsNumeric
returns " &
>IsNumeric(pvarValue1)
>
>pdblValue = CDbl(pvarValue1) + CDbl(pvarValue2) + CDbl
(pvarValue3)
>
>If Err.Number > 0 Then
> Response.Write "An error occurred during the
addition." & vbCrLf & "[" &
>Err.Number & "] " & Err.Description
> Err.Clear
>End If
>
>Response.Write "Result = '" & pdblValue & "' IsNumeric
returns " &
>IsNumeric(pdblValue)
>
>NB: The single quotes are just to see if there is
extraneous padding or
>extra characters in the form field values.
>
>Chris.
>
>"Patricia" <patricia@hitekdesigns.com> wrote in message
>news:021901c35943$25e80770$a301280a@phx.gbl...
>I did that, but get the same result. I also followed
>another thread where the solution was to use conversion
>functions, but I get an internal server error when I do
>that. thanks anyway.
>
>
>>-----Original Message-----
>>Patricia wrote on 02 aug 2003 in
>microsoft.public.scripting.vbscript:
>>
>>> I then add up the variables like:
>>>
>>> quantot = quantity1 + quantity2 + quantity3
>>>
>>> I also tried to use the conversion function for Cint
>and
>>> Csng, which made no difference.
>>>
>>
>>quantot = 1*quantity1 + 1*quantity2 + 1*quantity3
>>
>>
>>
>>--
>>Evertjan.
>>The Netherlands.
>>(Please change the x'es to dots in my emailaddress)
>>.
>>
>
>
>.
>

Re: can't add up numbers from form fields by Chris

Chris
Sun Aug 03 04:54:17 CDT 2003

Cool - 1 out of 2 ain't bad.

Might be a simple syntax error in my ASP (internal server error) somewhere -
I wasn't sure if Err.Number was the correct reference.
Cheers,

Chris.

"Pa tricia" <patricia@hitekdesigns.com> wrote in message
news:026701c35957$e4421a30$a501280a@phx.gbl...
I got an internal server error (500) when I added your
code. I tried remarking some of it out, but finally had
to remove it. But--Guess what? When I used your syntax:


quantot = Csng(quantity1) + Csng(quantity2)+ Csng
(quantity3)

it works. Thanks a lot. I don't know why the on error
code doesn't work.

>-----Original Message-----
>I don't want to sound daft here but the only possible
result value for:
>
>Dim pdblValue
>
>pdblValue = CDbl(pvarValue1) + CDbl(pvarValue2) + CDbl
(pvarValue3)
>
>is a number or an error.
>
>Try this test code to see what is output to the browser:
>
>On Error Resume Next
>
>'pvarValue1,2,3 are form the form fields.
>
>Response.Write "Value1 = '" & pvarValue1 & "' IsNumeric
returns " &
>IsNumeric(pvarValue1)
>Response.Write "Value2= '" & pvarValue1 & "' IsNumeric
returns " &
>IsNumeric(pvarValue1)
>Response.Write "Value3 = '" & pvarValue1 & "' IsNumeric
returns " &
>IsNumeric(pvarValue1)
>
>pdblValue = CDbl(pvarValue1) + CDbl(pvarValue2) + CDbl
(pvarValue3)
>
>If Err.Number > 0 Then
> Response.Write "An error occurred during the
addition." & vbCrLf & "[" &
>Err.Number & "] " & Err.Description
> Err.Clear
>End If
>
>Response.Write "Result = '" & pdblValue & "' IsNumeric
returns " &
>IsNumeric(pdblValue)
>
>NB: The single quotes are just to see if there is
extraneous padding or
>extra characters in the form field values.
>
>Chris.
>
>"Patricia" <patricia@hitekdesigns.com> wrote in message
>news:021901c35943$25e80770$a301280a@phx.gbl...
>I did that, but get the same result. I also followed
>another thread where the solution was to use conversion
>functions, but I get an internal server error when I do
>that. thanks anyway.
>
>
>>-----Original Message-----
>>Patricia wrote on 02 aug 2003 in
>microsoft.public.scripting.vbscript:
>>
>>> I then add up the variables like:
>>>
>>> quantot = quantity1 + quantity2 + quantity3
>>>
>>> I also tried to use the conversion function for Cint
>and
>>> Csng, which made no difference.
>>>
>>
>>quantot = 1*quantity1 + 1*quantity2 + 1*quantity3
>>
>>
>>
>>--
>>Evertjan.
>>The Netherlands.
>>(Please change the x'es to dots in my emailaddress)
>>.
>>
>
>
>.
>