Enable JavaScript in the browser to display LibreOfficeDev Help pages.

CSng Function

Chuyển đổi bất cứ biểu thức nào kiểu chuỗi hay thuộc số sang kiểu dữ liệu Đơn (Single).

Syntax:


CSng (Expression As Variant) As Single

Return value:

Single

Parameters:

Expression: Any string or numeric expression that you want to convert. To convert a string expression, the number must be entered as normal text using the default number format of your LibreOfficeDev locale settings. For instance, the number must be entered using a dot "." as the decimal point and a comma "," as the thousands separator (for instance 123,456.78) for the English locale setting.

Error codes:

5 Sai gọi thủ tục

Example:

Numeric expressions are displayed according to LibreOfficeDev locale settings:


Sub ExampleCountryConvert
    MsgBox CDbl(1234.5678) ' 1234.5678
    MsgBox CInt(1234.5678) ' 1235
    MsgBox CLng(1234+5678) ' 6912
    MsgBox CSng(1234.5678) ' 1234.567749023

    MsgBox CDbl(expression := 5678.1234) ' 5678.1234
    MsgBox CInt(expression := 5678.1234) ' 5678
    MsgBox CLng(expression := 5678+1234) ' 6912
    MsgBox CSng(expression := 5678.1234) ' 5678.123535156
End Sub