View Full Version : Convernt String to Numeric
Hi guys, simple question that I can't seem to find in my vbscript refrence. How do I convert a string to a numeric variable.
The string happens to be a cookie.
whammy
01-08-2003, 01:52 AM
First of all you want to be sure it exists...
If Request.Cookies("Cookiename") <> "" Then
If IsNumeric(Request.Cookies("Cookiename")) Then
' Do whatever you want here
End If
End If
Since all variables in ASP are actually of the type "Variant", you shouldn't have to "convert" it to numeric before performing a mathematical operation on it if it is indeed numeric (and I presume you set the cookie!). What are you trying to do, and what kind of information does the cookie contain? :)
P.S.
CInt(variable) = integer
CDbl(variable) = Double
and there's plenty more datatypes, look on MSDN
Thanks that code below works.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.