Hi Thelma
These suffixes are type declaration characters.
The $ at the end of the name is a way of declaring the variable As String.
The % at the end of the name declares the variable As Integer.
Early versions of BASIC used special characters at the end of the variable name to declare the data type. For example, the ampersand makes this variable a Long:
Dim Quantity&
This arcane style is still supported, but is less readable. One case where type declaration characters may be useful is with literal values. It is more efficient to compare two values of the same type, so you may want to code:
If Len(strMyString) = 0& Then
Since Len() returns a Long and the zero alone would be an Integer, using the type declaration character means VBA does not have to convert the Integer into a Long to perform the comparison each time this line is executed.
VBA itself uses the type declaration character in some string functions. For example, there are two functions for choosing the beginning characters from a string: Left$() returns a String, and Left() returns a Variant. Choosing the function that returns the correct type will be slightly more efficient.
I will incur the wrath of this community and post in HTML so as to include a table showing the type declaration characters and other info about the field types:
Type
Size
Range
JET Type
Initial Value
Decl Char
Prefix
Boolean
1-bit (effectively)
True/False
Yes/No
False
bool
(f, bln)
Byte
8-bit, unsigned whole number
0 to 255
Number (Byte)
0
byte
Integer
16-bit, signed whole number
-32768 to 32767
Number (Integer)
0
%
int
Long
32-bit, signed whole number
-2,147,483,648 to 2,147,483,647
Number (Long Integer)
0
&
lng
Single
32-bit, signed floating-point
3.402823E38 to -1.401298E-45;
1.401298E-45 to 3.402823E38
Number (Single)
0
!
sng
Double
64-bit, signed floating-point number
-1.79769313486231E308 to
-4.94065645841247E-324; 4.94065645841247E-324 to 1.79769313486232E308
Number (Double)
0
#
dbl
Currency
64-bit, signed fixed-point
-922,337,203,685,477.5808 to 922,337,203,685,477.5807
Currency
0
@
cur
Decimal (subtype)
96-bit signed scalable number.
+/-79,228,162,514,264,337,593,543,950,335 to +/-0.0000000000000000000000000001
Number (Decimal)
0
dec
Date
64-bit signed floating-point
January 1 100 to
December 31 9999
Date/Time
Dec. 30 1899
date (dtm)
String
Depends on length
Variable-length: approx. 2 billion
Fixed-length: up to 64k characters
Text
""
$
str
stf
Object
Address (32-bit)
sound, Word document, text box, printer, device, etc.
OLE Object
Nothing
obj
Variant
Any of the above (except fixed-length string), Empty, Null, Error, Nothing, DataObject, User-defined type
Empty
var
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users -
http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Thelma Lubkin" <th****@alpha2.csd.uwm.edu> wrote in message news:d8**********@uwm.edu...
I've been looking at code that handles string manipulation and I keep
seeing variable names, and function names, too, followed by a '$'.
I've also found a variable followed by a '%' symbol, but I've only
seen that once. Can someone please explain this for me? I haven't
been able to find anything about it.
thanks, --thelma