Conversion Functions

Conversion functions allow you to change the subtype of a variable.  VBScript assigns the variant type to all variables as a default, but there are many cases when you might have to convert a variable to a particular type to satisfy an argument.  A common example would be that you might have a string argument that returns a numeric value or a numeric argument that returns a string value.  Here are some of the most commonly used conversion functions:

CByte

CByte(strExample)

The CByte function converts this variable to a subtype byte.

 

CDbl

CDbl(strExample)

The CDbl function converts this variable to a subtype double.

 

CInt

CInt(strExample)

The CInt function converts this variable to a subtype integer.

 

CLng

CLng(strExample)

The CLng function converts this variable to a subtype long.

 

CStr

CStr(strExample)

The CStr function converts this variable to a subtype string.

< Back to ASP Scripts