Lotus Software logo
IBM Lotus Domino Designer 8.5
  Versions 8.5 and 8.5.1






Explicit data type conversion

LotusScript provides several built-in functions for explicitly converting a value's data type. These functions include CBool, CByte, CCur, CDat, CDbl, CInt, CLng, CSng, CStr, and CVar.

This example illustrates their use:

Dim aString As String

Dim anInt As Integer
Dim aDouble As Double
Dim myFixedPoint As Currency
Dim aVariantV as Variant

aString$ = "123"
' Convert the string "123" to a value of type Double.
aDouble# = CDbl(aString$)

' Add the prefix &H to that string, to
' prepare the string for conversion to a
' hexadecimal number.
aString$ = "&H" & aString$

' Convert the string "&H7B" to an integer,
' add 12.46 to that integer, explicitly
' convert the result to a value of type Currency,
' and assign it to a variable of type Currency.
' If you omit the step of explicitly converting
' the integer to a value of type Currency, the
' conversion happens automatically when the
' assignment takes place.
myFixedPoint@ = CCur(CInt(aString$) + 12.46)
Print myFixedPoint@
' Output: 135.46

' Explicitly convert a value of type Currency
' to an integer, with automatic rounding off,
' and assign the result to a variable of type
' Integer. If you don't explicitly convert
' the Currency value to an integer,
' conversion (with rounding) happens
' automatically when the assignment takes place.
anInt% = CInt(myFixedPoint@) + 300
Print anInt%
' Output: 435

' Convert an integer to a date value
' and assign it to a Variant variable.
aVariantV = CDat(anInt%)
Print format$(aVariantV, "mm/dd/yyyy")
' Output: 03/10/1901

Some conversion facts to keep in mind:

Related topics
Data Types, Constants, and Variables
Data type conversion
Bin function
CBool function
CByte function
CCur function
CDat function
CDbl function
CInt function
CLng function
CSng function
CStr function
CVar function




Library | Support | Terms of use |

Last updated: Monday, October 5, 2009