Click to See Complete Forum and Search --> : VBscript quick question


cw410005
10-17-2006, 05:14 AM
Sorry for such a newbie question!!

I have a form which gets a value on a page once this form is submitted I create a session variable on my next page


I then want to do some calculations on that number. Do I have to do anything like casting this string value to an integer? If so how do i do this


I thought this would work but doesnt:

Any advice would be a help.

<%session("num")=Request.Form("Number")

dim a
a=session("num")

a=a+5
Response.Write(a)
%>

Ribeyed
10-18-2006, 04:15 AM
Hi,
try this:

a =int(a) + 5

russell
10-18-2006, 11:45 AM
clng() instead of int() if number might be greater than 32,768

<%
session("num")=Request.Form("Number")

dim a
a=session("num")

If len(a) Then
a = clng(a)
Else
a = 0
End If

a=a+5
Response.Write(a)

%>