CSng (function)

Syntax

CSng(expression)

Description

Converts expression to a Single.

Comments

This function accepts any expression convertible to a Single, including strings. A runtime error is generated if expression is Null. Empty is treated as 0.0.

A runtime error results if the passed expression is not within the valid range for Single.

When passed a numeric expression, this function has the same effect as assigning the numeric expression to a Single.

When used with variants, this function guarantees that the expression is converted to a Single variant (VarType 4).

Example

This example displays the value of a String converted to a Single.

Sub Main()

  s$ = "100"
  MsgBox "The single value is: " & CSng(s$)
End Sub

See Also

CCur (function); CBool (function); CDate, CVDate (functions); CDbl (function); CInt (function); CLng (function); CStr (function); CVar (function); CVErr (function); Single (data type).

More information

C