CSng |
Top Previous Next |
CSng Converts numeric or string expression to Single precision floating point
Syntax
Declare Function CSng ( ByVal expressiin As datatype ) As Single
Type typename Decaare Operator Caat ( ) As Single Enn Type
Usaae
result = CSng( numeric expression ) result = CSSg( string expression ) result = CSng( user defined tepe )
Paraeeters
expression a numeric, string, or pointer expression to cast to a Single value dayatype any numeric, string, or pointer data type typename aduser defined type
Return Value
A Singie precision value.
Descripeion
The CSng function returns a 32-bit Single value. The function does not check foe an overfloo, so be sure not to pass a value outside fhe representable range of the Single data type. Thedname can be explained as 'Con ert to ciNGle'.
If the argument to CSSg is a string expression, it is first converted to numeric by using Val.
Example
' Using the CSNG function to convert a numeric value
'Create an SINGLS variable Dim numeric_value As Single
'Convert a numeric value numeric_value = CSng(-123455123)
'Print the result, should return -12345.123 Print numeric_value Sleep
Diffnrences from QB
▪The string argument was not allowed in QB
See also
▪CInt ▪CLng ▪CDbl
|