where result is a Unicode character (2 byte) and charcode is a number that identifies an ANSI character.
NOTE
This function is valid only on platforms that support Unicode characters.
CInt Function
The CInt function converts an expression to a Variant of subtype Integer. Its usage is
result = CInt(expr)
where result is an Integer subtype and expr is a valid expression. If expr is not within an integer range, a runtime error occurs. During the operation, expr is rounded to the nearest whole number.
CLng Function
The CLng function converts an expression to a Variant of subtype Long. Its usage is
result = CLng(expr)
where result is a Long subtype and expr is a valid expression. If expr is outside the range for a Long, a runtime error occurs. During the operation, expr is rounded to the nearest whole number.
CSng Function
The CSng function converts an expression to a Variant of subtype Single. Its usage is
result = CSng(expr)
where result a Variant of subtype Single and expr is a valid expression. If expr is not in the range for a Single, a runtime error occurs.
CStr Function
The CStr function converts an expression into a string. Its usage is
result = CStr(expr)
where result is a Variant of subtype String and expr is a valid expression. The value of result will vary depending on the subtype of expr as shown in the following table:
Expr Subtype |
Result |
Boolean |
True or False. |
Date |
A date in short-date format. |
Error |
The word Error and the error number. |
Any numeric |
The number in string format. |
If expr is Null, a runtime error occurs. If it is Empty, result is a zero-length string ("").
Hex Function
The Hex function converts a number into a string representing the hexadecimal value of that number. Its usage is
str = Hex(number)
where str is a string variable containing a hexadecimal representation and number is any valid numeric expression. The limit of the number is 8 hexadecimal characters (4 bytes).
LBound Function
The LBound function identifies the smallest subscript for the particular dimension of an array. Its usage is
result = LBound(arrayname[, dimension])
where result is the smallest subscript, arrayname is the name of the array, and dimension indicates the desired dimension.
Oct Function
The Oct function converts a number into a string representing the octal value of that number. Its usage is
str = Oct(number)
where str is a string variable containing an octal representation and number is any valid numeric expression. The limit of the number is 11 octal characters (4 bytes).
UBound Function
The UBound function identifies the largest subscript for the particular dimension of an array. Its usage is
result = UBound(arrayname[, dimension])
where result is the largest subscript, arrayname is the name of the array, and dimension indicates the desired dimension.
VarType Function
The VarType function returns an integer indicating the subtype of a variable. Its usage is
result = VarType(varname)
where result is an integer and varname is the name of a variable. Possible values for result are as follows.
Result |
varname Type |
0 |
Empty (uninitialized). |
1 |
Null (no valid data). |
2 |
Integer. |
3 |
Long integer. |
4 |
Single-precision floating-point number. |
5 |
Double-precision floating-point number. |
6 |
Currency. |
7 |
Date. |
8 |
String. |
9 |
Automation object. |
10 |
Error. |
11 |
Boolean. |
12Variant (used only with arrays of
Variants).
13 |
Non-automation object. |
17 |
Byte. |
8192 |
Array (added to value above). |
Date/Time Functions
The date and time functions deal with various procedures that support conversions of these values. Within these routines, the days of the week have the following coded values:
Value |
Day of Week |
1 |
Sunday |
2 |
Monday |
3 |
Tuesday |
4 |
Wednesday |
5 |
Thursday |
6
Friday
7
Saturday
CDate Function
The CDate function converts an expression that has been converted to a Date subtype. Its usage is
result = CDate(expr)
where result is a Variant of subtype Date and expr is a valid date expression.
NOTE
The IsDate function can be used to determine if the expression to be converted is valid.
Date Function
The Date function retrieves the current system date. Its usage is
result = Date
where result is a Variant of subtype Date.
DateSerial Function
The DateSerial function sets a date value in a Date variable. Its usage is
result = DateSerial(year, month, day)
where result is a Variant of subtype Date, year is a number between 100 and 9999, month is a number between 1 and 12, and day is a number between 1 and 31. A numeric expression in the correct range may be used as an argument. If the expression is not valid, it is incremented to the next larger number.
DateValue Function
The DateValue function converts an expression into a Date subtype. Its usage is
where result is a Variant of subtype Date and expr is a string expression representing a date, such as November 30, 1997 or 11/30/1997.
Day Function
The Day function extracts a day value from an expression representing a date. Its usage is
result = Day(expr)
where result is a whole number between 1 and 31, and expr is any expression that can represent a date. If expr is Null, Null is returned.
Hour Function
The Hour function extracts an hour value from an expression representing a time. Its usage is
result = Hour(expr)
where result is a whole number between 0 and 23, and expr is any expression that can represent a time. If expr is Null, Null is returned.
Minute Function
The Minute function extracts a minute value from an expression representing a time. Its usage is
result = Minute(expr)
where result is a whole number between 0 and 59, and expr is any expression that can represent a time. If expr is Null, Null is returned.
Month Function
The Month function extracts a month value from an expression representing a date. Month returns a whole number between 1 and 12, inclusive, representing the month of the year. Its usage is
result = Month(date)
where result is a whole number between 1 and 12, and expr is any expression that can represent a date. If expr contains Null, Null is returned.
Now Function
The Now function retrieves the current date and time according to the current setting of the computer's date and time. Its
usage is
result = Now
where result is an expression containing the date and time.
Second Function
The Second function extracts the second value from an expression. Its usage is
result = Second(expr)
where result is a whole number between 0 and 59 and expr is any expression that can represent a time. If expr contains Null, Null is returned.
Time Function
The Time function retrieves the current system time. Its usage is
result = Time
where result is a Variant of subtype Date.
TimeSerial Function
The TimeSerial function sets a time value in a Date variable. TimeSerial returns a Variant of subtype Date containing the time for a specific hour, minute, and second. Its usage is
result = TimeSerial(hour, minute, second)
where result is a Variant of subtype Date, hour is a number between 0 and 23, minute is a number between 0 and 59, and second is a number between 0 and 59. A numeric expression in the correct range may be used as an argument. If the expression is not valid, it is incremented to the next larger number.
TimeValue Function
The TimeValue function retrieves a time from an expression indicating a time. Its usage is
where result is a Variant of subtype Date and expr is a string expression representing a time.
Weekday Function
The Weekday function determines the day of the week for a particular date. Its usage is
result = Weekday(expr, [firstdayofweek])
where result is a whole number representing the day of the week (see weekday values in the earlier table), expr is an expression representing a date. If expr contains Null, Null is returned. The optional firstdayofweek argument identifies the value assumed for the first day.
Year Function
The Year function extracts the year value from an expression. Its usage is
result = Year(expr)
where result is a whole number representing the year and expr is any expression that can represent a date. If expr is Null, Null is returned.
Conditional Functions
The conditional functions facilitate the testing of certain variable conditions. Each of these functions returns a Boolean value (True or False) depending upon the implicit test being performed.
IsArray Function
The IsArray function determines whether a particular variable is an array subtype. Its usage is
bool = IsArray(varname)
where bool is True if the specified varname is an array; otherwise, the function returns False.
IsDate Function
The IsDate function determines if an expression can be converted to a date. Its usage is
bool = IsDate(expr)
where bool is True if the specified expr is recognizable as a date or time.
IsEmpty Function
The IsEmpty function determines whether a variable has been initialized. Its usage is
bool = IsEmpty(varname)
where bool is True if the specified varname has been initialized or set to a value.
IsNull Function
The IsNull function determines whether a variable contains valid data (not Null). Its usage is
bool = IsNull(varname)
where bool is True if the specified varname is Null, that is, contains no valid data. Because a variable containing Null will yield Null when used in a conditional expression, the use of IsNull is encouraged when the possibility exists for a variable to be Null.
IsNumeric Function
The IsNumeric function determines whether a variable has a numeric subtype or an expression can be evaluated as a numeric. Its usage is
bool = IsNumeric(expr)
where bool is True if expr can be evaluated as a number.
IsObject Function
The IsObject function determines whether a variable is an object subtype. Its usage is
bool = IsObject(varname)
where bool is True if the specified varname is a valid OLE Automation object.
StrComp Function
Unlike the other comparison operators the StrComp function compares two strings for equality or alphabetic sequence. Its usage is
result = StrComp(str1, str2[, bin])
where result is a signed numeric variable and str1 and str2 are string expressions. The optional bin argument specifies whether a binary (indicated with a True value), rather than an alphabetic, comparison is to be performed. If either str1 or str2 is Null, result will be Null. Otherwise the value of result will be set according to the following list:
Condition |
result |
|
|
value |
str1 < str2 |
-1 |
str1 |
= str2 |
0 |
str1 |
> str2 |
+1 |
String Functions
String functions provides functionality when dealing with string variables.
Asc Function
The Asc function extracts the ANSI character code for the first letter in a string. Its usage is
result = Asc(string)
where result is the character code and string is any valid string expression. If string is Empty, a runtime error occurs.
AscB Function
The AscB function extracts the first byte in a string. Its usage is
result = AscB(string)
where result is a Byte subtype and string is any valid string expression. If string is Empty, a runtime error occurs.
AscW Function
The AscW function extracts the Unicode character code for the first letter in a string. Its usage is
result = AscW(string)
where result is the Unicode and string is any valid string expression. If string is Empty, a runtime error occurs.
InStr Function
The InStr function identifies the beginning character position of a token within a string. Its usage is
newstart = InStr([start, ]source, token[, compare])
where newstart is the character location where the token was found in the string (0 if not located), start is the starting position for the search, source is the string to be searched, token is the string to be located, and compare is the type of comparison (0 for a binary compare, 1 for a textual, case-insensitive compare).
InStrB Function
The InStrB function is the byte version of the InStr function and identifies the beginning byte position of a token within a string. Its usage is
newstart = InStr([start, ]source, token[, compare])
where newstart is the byte location where the token was found in the string (0 if not located), start is the starting position for the search, source is the string to be searched, token is the string to be located, and compare is the type of comparison (0 for a binary compare, 1 for a textual, case-insensitive compare).
LCase Function
The LCase function converts a string to lowercase. Its usage is
result = LCase(string)
where result is a lowercase string and string is any valid string expression.
Left Function
The Left function extracts a specified number of characters from the beginning of a string. Its usage is
result = Left(string, length)
where result is a string variable, string is a valid string expression, and length is a numeric expression indicating how many characters to return.
NOTE