?
Solved

Using vartype to detect vbLong

Posted on 2005-04-27
7
Medium Priority
?
291 Views
Last Modified: 2008-02-01
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.
0
Comment
Question by:joekus
  • 3
  • 3
7 Comments
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 13881043
I suspect that it is interpreting it as a string.

Perhaps something like:

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


FtB
0
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 1500 total points
ID: 13881153
Or:
mem_no = CLng(request.queryString("mem_no"))
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 13881174
@ACPerkins--

If you have a minute, stick your head in here:

http://www.experts-exchange.com/Web/Web_Languages/ASP/Q_21402752.html#13881017

FtB
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:joekus
ID: 13881194
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.
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 13881218
That is going to be tough since VBScript variables are essentially variants unless specifically cast into a type....


FtB
0
 

Author Comment

by:joekus
ID: 13881396
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
0
 

Author Comment

by:joekus
ID: 13881520
Actually I had to use
if mem_no/CLNG(mem_no) =1 as solution so thanks to acperkins
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question