| Integer | Contains integer in the range -32,768 to 32,767. | 2 | CInt |
| Currency | -922,337,203,685,477.5808 to 922,337,203,685,477.5807. | 6 | CCur |
| Long | Contains integer in the range -2,147,483,648 to 2,147,483,647. | 3 | CLng |
| Single | Contains a single-precision, floating-point number in the range -3.402823E38 to -1.401298E-45 for negative values; 1.401298E-45 to 3.402823E38 for positive values. | 4 | CSng |
| Double | Contains a double-precision, floating-point number in the range -1.79769313486232E308 to -4.94065645841247E-324 for negative values; 4.94065645841247E-324 to 1.79769313486232E308 for positive values. | 5 | CDbl |
| Date (Time) | Contains a number that represents a date between January 1, 100 to December 31, 9999. | 7 | CDate |
| String | Contains a variable-length string that can be up to approximately 2 billion characters in length. | 8 | CStr |
The following code demonstrates the usage of VarType and function converting variable to integer subtype.
<html> <head> <script language="VBScript"> sub DataType'Starting the subroutinedim s'Variable declaration s="10"'Variable initialization as string subtype msgbox VarType(s) s=cint(s)'Variable conversion to integer subtype msgbox VarType(s) end sub </script> </head>
<body onload="DataType"> </body> </html>
In the above program the variable s is initialized as string subtype (by enclosing the number in quotation marks). The standard msgbox VBScript function displays the value returned by VarType function (8, see Table). After that the variable is converted to integer subtype as can be seen by invoking again the msgbox function (number 2 is returned).
Go To Page: 1 2
Articles in this Topic Discussions in this Topic