Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

true = -1 and false = 0 1

Status
Not open for further replies.

theEclipse

Programmer
Dec 27, 1999
1,190
US
Can someone please verify for me that this is how bad things really are?

I did this
Code:
<% response.write(cint(false) & " " & cint(true)) %>

and got: 0 -1

why do I care?

because cint("") is zero, so
if cint(request.form("count"))>-1 then
....
end if
will execute if request.form("count")[ol A][li] doesnt exist[/li][li]is greater than -1 (as it should)[/li][li]and if it is false!!!![/li][/ol]

does this seem abit annoying to anyone else?

anybody have any ideas as to how to get around it?

all I want is to test and see if a value exists and if it is a number greater than -1

Robert Carpenter
"You and I have need of the strongest spell that can be found to wake us from the evil enchantment of worldliness." - C.S. Lewis (The Weight of Glory)

robert (at) robertcarpenter (dot) net
 
Yah, thanks for that correction :)

The only other change I feel I should mention is to point out that you could simply:
Code:
If isPosNumeric(Request("count")) Then
   count = cInt(Request("count"))
End If
The reason this works is that trhe Request object will magically search all of it's internal collecitons for the first existing keyed value that matches the key name your passing. The good thing about this is that your code looks shorter, the bad thing is that it is less efficient. The basic search order is something like Form, QueryString, Cookies, (something else...ServerVariables?). That means that if your count value isn't in either .Form or .Querystring it is still committed to two more searches before it returns the empty value. Even so, I thought it was worth mentioning.

-T

barcode_1.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top