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.
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
@ACPerkins--
If you have a minute, stick your head in here:
https://www.experts-exchange.com/questions/21402752/Expand-current-search-page-to-pass-many-parameters-to-a-stored-procedure.html#13881017
FtB
If you have a minute, stick your head in here:
https://www.experts-exchange.com/questions/21402752/Expand-current-search-page-to-pass-many-parameters-to-a-stored-procedure.html#13881017
FtB
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.
response.write(vartype(mem
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
FtB
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
mem_no mod 1 gives a result of 0 which is sufficient for what I am trying to determine
Thank you for your efforts
ASKER
Actually I had to use
if mem_no/CLNG(mem_no) =1 as solution so thanks to acperkins
if mem_no/CLNG(mem_no) =1 as solution so thanks to acperkins
Perhaps something like:
mem_no = CDbl(request.queryString("
FtB