CSng function
Returns an expression that has been converted to a Variantof a single subtype.
CSng(expression)
The expression parameter is any valid expression.
Description
In general, you can use a subtype conversion function to write code to show that the results of some operations should be represented as a specific data type, not the default type. For example, in the case of currency or integer operations, use CDBL or csng to force double or single precision operations.
The csng function is used for internationally recognized format conversions from other data types to single subtypes. For example, the recognition of decimal separators, such as the thousand characters, depends on the locale of the system.
If expression is outside the range allowed by the single subtype, an error occurs.
The following example uses the csng function to convert a value to single:
Dim MyDouble1, MyDouble2, MySingle1, MySingle2 is a double value. MyDouble1 = 75.3421115: MyDouble2 = 75.3421555 CSng(MyDouble1) ' MySingle1 contains . CSng(MyDouble2) ' MySingle2 contains .