Search here for all the info you want in this Blog

Conversion Functions

You can use conversion functions to convert data from one subtype to another. In addition, the VarType function returns information about how your data is stored within a Variant.

VBScript supports the following commonly used conversion functions:
CBool(vVariant) - Converts an expression to a variant of subtype Boolean
CByte(vVariant) - Converts an expression to a variant of subtype Byte
CCur(vVariant) - Converts an expression to a variant of subtype Currency
CDate(vVariant) - Converts a valid date and time expression to the variant of subtype Date
CDbl(vVariant) - Converts an expression to a variant of subtype Double
CInt(vVariant) - Converts an expression to a variant of subtype Integer
CLng(vVariant) - Converts an expression to a variant of subtype Long
CSng(vVariant) - Converts an expression to a variant of subtype Single
CStr(vVariant) - Converts an expression to a variant of subtype String

Example :

document.writeln("7=" & (7) & " : " & TypeName(7))
document.writeln("CByte(7)=" & (CByte(7)) & " : " _ & TypeName(CByte(7)))
 document.writeln("777=" & (777) & " : " & TypeName(777))
 document.writeln("777777=" & (777777) & " : " & TypeName(777777))
 document.writeln("9.99=" & (9.99) & " : " & TypeName(9.99))
 document.writeln("CSng(9.99)=" & (CSng(9.99)) & " : " & TypeName(CSng(9.99)))
 document.writeln("0.00314159e30=" & (0.00314159e30) & " : " &TypeName(0.00314159e30))
 document.writeln("333.333e200=" & (333.333e200) & " : " & TypeName(333.333e200))
 document.writeln("CCur(9.99)=" & (CCur(9.99)) & " : " & TypeName(CCur(9.99)))
 document.writeln("""Hello""=" & ("Hello") & " : " & TypeName("Hello"))
 document.writeln("TRUE=" & (TRUE) & " : " & TypeName(TRUE))
 document.writeln("#31-Dec-1999#=" & (#31-Dec-1999#) & " : " & TypeName(#31-Dec-1999#))
 document.writeln("Empty=" & (Empty) & " : " & TypeName(Empty))
 document.writeln("Null=" & (Null) & " : " & TypeName(Null))

No comments:

Post a Comment