[thelist] ASP: DIM var AS ??

Ken Schaefer ken at adOpenStatic.com
Thu Jul 3 04:13:58 CDT 2003

No one seems to have explained why this is happening. So I'll give it a go.
There is only two types in VBScript: the Variant, and Object. Now, we're not
dealing with an Object, so let's talk about Variants

Variants have subtypes. You can cast a variant to a particular subtype using
the C...() functions (eg CInt() etc). Usually, when you do comparisons, the
subtypes are the same -or- are implicitly casted for you by the VBScript
interpretor. Sometimes they aren't.

Good, defensive, coding means that when you getting values from
anywhere -outside- your system, you make sure you know what's in them.

lngCat = Request.QueryString("Cat")
If isNumeric(lngCat) then
    intCat = CLng(lngCat)
    ' Throw some kind of exception
    ' or substitute a default value
End If

' Now you know lngCat is some kind of whole number. You can compare that to
any other variable you know contains a whole number


----- Original Message ----- 
From: "Casey Crookston" <casey at thecrookstons.com>
To: <thelist at lists.evolt.org>
Sent: Thursday, July 03, 2003 6:39 AM
Subject: [thelist] ASP: DIM var AS ??

: Hello Listers,
: Question: what is the syntax to define a variable as an integer?
: I have a VERY simple if then statement:
: if cat = cat_id then
:    klass="navigation2"
: else
:    klass="navigation"
: Weird thing... ONLY the "else" gets triggered, even when cat and cat_id
: equal.  I have checked and double checked (even response.wrote the two
: to the screen) but for what ever reason klass will never be equal to
: "navigation2".  Ever.  Even when cat = cat_id.
: About the only thing I can figure is that cat is being defined as a string
: and cat_id as a number (or vise versa).  So I need to know how to specifiy
: that both are integers.
: Thanks,
: Casey
: -- 
: * * Please support the community that supports you.  * *
: http://evolt.org/help_support_evolt/
: Evolt.org conference in London, July 25-27 2003.  Register today at
: For unsubscribe and other options, including the Tip Harvester
: and archives of thelist go to: http://lists.evolt.org
: Workers of the Web, evolt !

More information about the thelist mailing list