KidsLovePC Contact Us
  Home   PHP  Graphics ASP  JavaScript   J2EE  HTML  JAVA   Swing   Webtip  Forums  Lyric  Free sheet music  Ringtones

What is variant?

A Variant is the only variable type provided in the VBScript scripting engine for ASP. Although variants don't have most efficeint use of memory and require extra processing compared to the more usual base data types such as Integer, variants do have their own advantages: Variants automacally handle implicit type conversion, which permit to ignore the difference among base data types. For example, we can use a variant storing String as an Integer as needed.

Example 1: using typename to return a variant subtype

<title>Using TypeName</title>
Dim dblPi,whatisPi,datToday, whatisDate,strText,whatisText


strText="Hello World"

Dim emp
<P><b>dblPi returns <%=whatIsPi%></p>
<p>datToday returns <%=whatIsDate%></p>
<p>strText returns <%=whatIsText%></p>
<p> emp return <%=emptyVar%></b></p>

How is works:
Alghough each variable is defined by default as a variant, it assumes the subtype of the data that is stored in it. Hence when the code is executed it returns Double, Date, String and Empty. Rember vbscript is not case sensitive.

The above code return like :

dblPi returns Double

datToday returns Date

strText returns String

emp return Empty

Example 2: Converting varants from one subtype to another

It will often be the case that you will need to read in data as a string, then perform numerical operations on it. In order to do this, you will need bo convert the data from a string data type to a double. Using functions, Cint,CSng,Cstr we can convert between numeric and string datatypes.

<title> Converting Variants</title>
<% Dim strPi, dblPi,intPi,strPi2,whatisPi1,whatisPi2,whatisPi3,whatisPi4
<p><B>Pi is a <%=whatispi1%> and Pi returns <%=strpi%></b></P>
<p><B>Pi is a <%=whatispi2%> and Pi returns <%=dblPi%></b></P>
<p><B>Pi is a <%=whatispi3%> and Pi returns <%=intPi%></b></P>
<p><B>Pi is a <%=whatispi4%> and Pi returns <%=strPi2%></b></P>

How it works:

strPi is initially a string subtype. The statement:
dblPi=CSng(strpi) changesi ti to Single subtype and saves the result in dblPI.
Similarly for the other statement.

ASP tutorial
What is ASP
Install IIS
VBScript or JScript
ClientSide vs ServerSide scripting
ASP execution order
Dealing with Form
More Form example
Variable &Variant
Local variable
Global variable
Use if_then_else
Use Select Case
For_Next loop
Do_while loop
Subroutine vs Function
Request Object
Count Keyword
Using QueryString
Application, Method, Events
Create Virtual Directory
Save array in Application
Session, Method, Events
Using Cookie
Server Object
Ad Rotator
Content Linker
Dictionary object
Filesystemobject Object




Best books about ASP & ASP.Net from Amazon
Beginning Dynamic Websites : with ASP.NET Web Matrix (Programmer to Programmer) (Paperback) Build Your Own ASP.NET Website Using C# & VB.NET (Build Your Own) (Paperback) Professional Active Server Pages 3.0 (Programmer to Programmer) (Paperback) ASP.NET Cookbook (Paperback) ASP.NET Kick Start (Paperback)


Printer Inkjet A Z lyricsLearn ChineseHome|PHP|Swing|HTML|JavaScript|ASP|JAVA|Forum|WebTip|Contact Us
Copyright © All rights reserved(new). Privacy|Copyright
designed by

Please help us cover the web site maintenance fee.
barcode scanner Thermal Printer credit card machine bar code printer