Siebel VB Language Reference > VB Language Reference >

CLng Function

This standard VB function converts an expression to the data type long by rounding.





Any expression that can evaluate to a number


The value of expression as a number of type long.


After rounding, the resulting number must be within the range of -2,147,483,648 to 2,147,483,647, or an error occurs.

Strings that cannot be converted to a long result in a Type Mismatch error. Variants containing null result in an Illegal Use of Null error.


This example divides the US national debt by the number of people in the country to find the amount of money each person would have to pay to wipe it out. This figure is converted to a long integer and formatted as currency.

Sub Button_Click
   Dim debt As Single
   Dim msgtext
   Const Populace = 250000000
   debt = 8000000000000
   msgtext = "The $/citizen is: " & _
      Format(CLng(Debt/ Populace), "Currency")
End Sub

See Also

CCur Function
CDbl Function
CInt Function
CSng Function
CStr Function
CVar Function
CVDate Function

Siebel VB Language Reference