Variables
String variables:
store characters enclosed in quotation marks
DIM variable_name As STRING
variable_name = value
InputBox(Prompt:= prompt [,Title:= title] [,Default:= default]
string1& “ “ & string2
Val(String:=string)
Working with strings
|
Display messages to user |
MsgBox |
|
Extract part of a string |
Mid, Left, Right |
|
Find length of a string |
Len |
|
Input text from user |
InputBox |
|
Trim leading and/or trailing spaces |
LTrim, RTrim, Trim |
|
Format |
Format |
|
Returns the position where one string begins with another string |
Instr |
|
Returns a string in uppercase |
UCase |
|
Replaces one string with another |
Replace |
|
Reverses the order of text in a string |
StrRev |
Date variables: store
date and time information
DIM variable_name As DATE
Format(Expression:= expression, Format:= format)
e.g.,
Format(Expression:=#11/5/2002#, Format:=”Short Date”) à
DateAdd(Interval:= interval, Number:= number, Date:= date)
|
Interval setting |
Description |
|
“yyyy” |
Year |
|
“q” |
Quarter |
|
“m” |
Month |
|
“y” |
Day of year |
|
“d” |
Day |
|
“w” |
Weekday |
|
“ww” |
Week |
|
“h” |
Hour |
|
“n” |
Minute |
|
“s” |
Second |
e.g.,
DateAdd(Interval:=”yyyy”, Number:=2, Date:=#1/1/2002#) à
DateDiff(Interval:= interval, Date1:= date1, Date2:= date2)
DateValue(Date:= stringExpression)
e.g., DateValue(Date:=”
Working with dates
|
Returns the specified part of a date |
DatePart |
|
Returns the interval of time between two dates |
DateDiff |
|
Returns the result of adding/subtracting a specified period of time to a date |
DateAdd |
|
Returns the text string associated with a month number |
MonthName |
Other variables
|
Data type |
Storage size |
Range |
|
Byte |
1 byte |
0 to 255 |
|
Boolean |
2 bytes |
True or False |
|
Integer |
2 bytes |
-32,768 to 32,767 |
|
Long |
4 bytes |
-2,147,483,648 to 2,147,483,647 |
|
Single |
4 bytes |
-3.402823E38 to -1.401298E-45
for negative values; 1.401298E-45 to 3.402823E38 for positive values |
|
Double |
8 bytes |
-1.79769313486231E308 to |
|
Currency |
8 bytes |
-922,337,203,685,477.5808 to
922,337,203,685,477.5807 |
|
Decimal |
14 bytes |
+/-79,228,162,514,264,337,593,543,950,335
with no decimal point; |
|
Date |
8 bytes |
|
|
Object |
4 bytes |
Any Object reference |
|
String |
10 bytes + string length |
0 to approximately 2 billion |
|
String |
Length of string |
1 to approximately 65,400 |
|
Variant |
16 bytes |
Any numeric value up to the
range of a Double |
|
Variant |
22 bytes + string length |
Same range as for
variable-length String |
|
User-defined |
Number required by elements |
The range of each element is the
same as the |