CSNG(expression)

Returns the expression converted to a single data type (Single).


expressionThe expression to evaluate and convert to a single.

REMARKS
* The Single data type is a Value data type.
* The "expression" can be any number between - 1.3 E+38 and + 1.3 E+38.
* If the expression passed to the function is outside the range of the data type being converted to, an error occurs.
* The range for a double data type is: - 1.8 E+308 to + 4.9 E+324.
* This function uses the locale setting to identify the different decimal separators and thousand separators.
* You can use the CDBL function to return an expression converted to a Double data type.
* You can use the CINT function to return an expression converted to an Integer data type.
* You can use the CLNG function to return an expression converted to a Long data type.
* For a full list of conversion functions refer to the Explicit Conversion page.
* For the Microsoft documentation refer to learn.microsoft.com

Debug.Print CSng("-100")    '= -100  
Debug.Print CSng("100-") '= -100
Debug.Print CSng("0.00") '= 0

Dim sngNumber As Single
Dim dbValue As Double
dbValue = 100.123
sngNumber = CSng(dbValue)
Debug.Print sngNumber

© 2022 Better Solutions Limited. All Rights Reserved. © 2022 Better Solutions Limited Top