TypeName, VarType and type checks in VBScript

In ASP we can check what type of ( data ) variable it is before using. We can use the function VarType to display a value for associated with each Variant subtype. TypeName() returns a readable type name, while VarType() returns a numeric subtype code.

We can check for a specific type by using the function IsArray, isDate etc functions. These are useful while developing code for further processing while working with variables.

Let us start with some syntax of TypeName function.
Dim v1 'Declaring variable v1
v1="Welcome"  'assigning value   
Response.Write "Value of v1=" & v1 
Response.Write "<br> v1 is a <i>" & TypeName(v1)  & "</i> variable "
In the above code we have declared v1 as a variable and assigned a string data to it. So now the variable v1 became string variable. So we will get an output like this by using the above code.
Value of v1=Welcome
v1 is a String variable
We can change the value of v1 to different values and see the type of variable TypeName function returns.

We can also check whether a value is an array by using IsArray to get true or false. Here is the code for this.
Dim v1 'Declaring variable v1
v1="Welcome"  'assigning value
Response.Write "Value of v1=" & v1 
Response.Write "<br>is v1 an array?  <i>" & isArray(v1)  & "</i>  " 
The output of the above code is shown here.
Value of v1=Welcome
is v1 an array? False

ASP Home






✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer