Siebel VB Language Reference > VB Language Reference >
This standard VB function converts an expression to the data type single.
Any expression that can evaluate to a number
The value of expression as a single-precision floating-point number.
The expression must have a value within the range allowed for the single data type, or an error occurs.
Strings that cannot be converted to an integer result in a Type Mismatch error. Variants containing null result in an Illegal Use of Null error.
This example calculates the factorial of a number. A factorial (notated with an exclamation mark, !) is the product of a number and each integer between it and the number 1. For example, 5 factorial, or 5!, is the product of 5*4*3*2*1, or the value 120.
Dim number as Integer
Dim factorial as Double
Dim msgtext As String
number = 25
If number <= 0 then
factorial = 1
For x = number to 2 step -1
factorial = factorial * x
'If number <= 35, then its factorial is small enough to
' be stored as a single-precision number
If number< 35 then
factorial = CSng(factorial)
msgtext = "The factorial of " & number & " is " & factorial