Literal Constants

A literal constant is a specific value such as number, date or text string that does not change.


Numerical constants

Dim myLong As Long 
myLong = 50
Dim myCurrency As Currency
myCurrency = 922337203685477.5807@


Date constants are enclosed between two hash signs #01/07/2014#.

Dim dtExpiryDate As Date 
dtExpirydate = #01/07/2010#


String constants are enclosed between double speech marks.
To include a double speech mark inside a text string you need to prefix it with another double speech mark.

Dim sText1 As String 
Dim sText2 As String
sText1 = "some "" text"
sText2 = "some" & """" & "text"
Debug.Print sText1 '= "some " text"
Debug.Print sText2 '= "some " text"

© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext