Link to home
Start Free TrialLog in
Avatar of joekus
joekus

asked on

Using vartype to detect vbLong

I plan on giving members encoded numbers added to the end of a URL.  (e.g.(http://homesite/valid.asp?mem_no=123456)
The page does a calculation and does a SQL query on a db.
Problem is if an incorrect number is entered, a long may result, so I bypass the query (as it will only work with integers and longs).  However, the calculated values are all returning doubles, even when they are integers or longs.

I am using statement:

    if vartype(mem_no) =  3  or if vartype(mem_no) =  2

which I hoped would weed out non-valid numbers, but it's weeding them all out.

I'm hoping you can point to a more elegant solution.
Avatar of fritz_the_blank
fritz_the_blank
Flag of United States of America image

I suspect that it is interpreting it as a string.

Perhaps something like:

mem_no = CDbl(request.queryString("mem_no"))


FtB
ASKER CERTIFIED SOLUTION
Avatar of Anthony Perkins
Anthony Perkins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of joekus
joekus

ASKER

No, when I

response.write(vartype(mem_no))

it returns a 5 (=Double) already for any value.  I need int(2) or long(3) when they are and anything else when they are not.
That is going to be tough since VBScript variables are essentially variants unless specifically cast into a type....


FtB
Avatar of joekus

ASKER

Found a solution--
mem_no mod 1 gives a result of 0 which is sufficient for what I am trying to determine

Thank you for your efforts
Avatar of joekus

ASKER

Actually I had to use
if mem_no/CLNG(mem_no) =1 as solution so thanks to acperkins