Go to: Articles List

All About Variables Part 3 : Checking for specific SubTypes
Part 1 | Part 2 | Part 3

There are six different functions that will assist you in determining if a particular variable is one Subtype or another. Below I have listed all of the SubType checking functions:

IsArray(VariableToCheck)
IsDate(VariableToCheck)
IsEmpty(VariableToCheck)
IsNull(VariableToCheck)
IsNumeric(VariableToCheck)
IsObject(VariableToCheck)

All of the above functions return a boolean value (true or false). Some of the above are self explanatory, however a few are not as clear. I will go over the ones that need explaining:

IsEmpty(VariableToCheck)
What makes a variable empty? If the variable has been created, but has not been assigned a value yet it is considered to be empty. This is different from a value that is empty ("") or equal to NULL.

IsNull(VariableToCheck)
What makes a variable null? A variable is null only when it equals null. You can set a variable equal to null.

IsNumeric(VariableToCheck)
This will return true if the variable can be converted to a numeric SubType without generating an error.

Example:

myVar = "Hello"
If IsNumeric(myVar) Then
Response.Write("Variable is numeric.")
Else      Response.Write("Variable is NOT numeric.")
End If

Result:
Variable is NOT numeric.

Another way to determine the variable SubType is the VarType() function.

Syntax:
VarType(VariableToCheck)

The above function will return a number representing the various subtypes. I have listed them for you below:

 Subtypes Value Description vbEmpty 0 Not assigned a value vbNull 1 No matching SubType vbInteger 2 Integer vbLong 3 Long vbSingle 4 Single vbDouble 5 Double vbCurrency 6 Currency vbDate 7 Date vbString 8 String vbObject 9 Object vbError 10 Error vbBoolean 11 Boolean (true or false) vbVariant 12 Variant, array of variants only vbDataObject 13 Data Access vbDecimal 14 Decimal vbByte 17 Byte vbArray 8192 Array