Getting the variable type and checking in ASP

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 type of variable. This value is a number so linking this number to type of data is to be done. There is another function TypeName which displays the Data type directly without any associated value.

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 create a double variable and check with isArray function 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

Be the first to post comment on this article :

plus2net.com




Post your comments , suggestion , error , requirements etc here .




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