LOTUSSCRIPT LANGUAGE


Examples: CLng function
Example 1

' Convert string to long

' Display value and data type

Dim nvar As Variant

Dim nstr As String

nstr = Inputbox("Number", "Enter any number", "0")

If Isnumeric(nstr) Then

nvar = Clng(nstr)

Messagebox nvar,, Typename(nvar)

Else

Messagebox nstr,, "Not a number"

End Sub

Example 2

' Convert Double and String values to Long, rounding up or down as indicated.
Dim x As Double, y as String

x# = 13.400556

Print CLng(x#) 'Prints 13

x# = 13.67

Print CLng(x#) 'Prints 14

y="1.345"

Print CLng(y) 'Prints 1

y="1.678"

Print CLng(y) 'Prints 2

y="string"

Print CLng(y) 'returns a type mismatch error

See Also