Page 44 - Excel for Scientists and Engineers: Numerical Methods
P. 44
CHAPTER 2 FUNDAMENTALS OF PROGRAMMING WITH VBA 21
Table 2-3. Some VBA Text Functions
Asc Returns the ASCII character code of a character.
Chr Returns the character corresponding to an ASCII code.
Format Formats a number according to a built-in or user-defined
number format expression. The result is a string.
lnstr Returns the first occurrence of a substring within a string.
Similar to Excel's FIND worksheet function.
Len Returns the length (number of characters) in a string.
Left Returns the leftmost characters of a string.
Right Returns the rightmost characters of a string.
Mid Returns a specified number of characters from a string.
LTrim Returns a string without leading spaces.
RTrim Returns a string without trailing spaces.
Trim Returns a string without leading or trailing spaces.
Str Converts a number to a string. A leading space is reserved
for the sign of the number; if the number is positive, the
string will contain a leading space.
LCase Converts a string into lowercase letters.
UCase Converts a string into uppercase letters.
VBA also provides a number of information functions, including eight "Is"
functions, shown in Table 2-4.
Table 2-4. VBA Information Functions
IsArray Returns True if the variable is an array.
IsDate Returns True if the expression is a date.
IsEmpty Returns True if the variable is uninitialized.
IsError Returns True if the expression returns an error.
IsMissing Returns True if an optional value has not been passed to a
Function procedure.
IsNull Returns True if the expression is null (i.e., contains no
valid data).
IsNumeric Returns True if the expression can be evaluated to a
number.
Isobject Returns True if the expression references a valid object.
LBound Returns the lower limit of an array dimension.
UBound Returns the upper limit of an array dimension.
All the above Is functions have the syntax FunctionName(argument) and
return either True or False.