Data Type: Numeric or String
The range of
-3.402823E38 to -1.401298E-45 for negative values;
1.401298E-45 to 3.402823E38 for positive values.
expression cast as a type of
Returns a single-precision number.
expression must evaluate to a
numeric value; otherwise, a type mismatch error is
If the value of
outside the range of the Single data type, an overflow error is
Dim sngMyNumber If IsNumeric(sMyNumber) then sngMyNumber = CSng(sMyNumber) End If
If you need to use a floating-point number in VBScript, there is no reason to use a Single; use a Double instead. Generally, a Single is used because it offers better performance than a Double, but this is not true in VBScript. Not only is a Single not smaller than a Double in the VBScript implementation, but the processor also converts Singles to Doubles, performs any numeric operations, and then converts Doubles back to Singles.
to a number by using the IsNumeric