CSNG

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.
* This function does no rounding.
* 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.
* 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.
* You can use the FIX function to return the integer portion of a number (truncating towards zero) (data type).
* You can use the INT function to return the number rounded down to the nearest integer.
* You can use the ROUND function to return a number rounded to a given number of decimal places.
* 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 sgNumber As Single
Dim dbValue As Double
dbValue = 100.123
sgNumber = CSng(dbValue)
Debug.Print sgNumber

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