Microsoft Office Tutorials and References
In Depth Information
7.4 Miscellaneous Functions and Statements
The StrCmp function also compares two strings. Its syntax is:
StrComp( string1 , string2 [, compare ])
and it returns a value indicating whether string1 is equal to, greater than, or less than
string2 . For more details, check the VBA help file.
7.4 Miscellaneous Functions and Statements
Of the wealth of functions offered by the VBA language, we'll focus on the Is... functions to
determine an attribute of a variable or object, the conversion functions, and two functions, IIf
and Switch , that return a conditional result.
7.4.1 The Is Functions
VBA has several Is functions that return Boolean values indicating whether or not a certain
condition holds. We have already discussed the IsMissing function in connection with optional
arguments. Here are some additional Is functions. The IsDate function
Th is function indicates whether an expression can be converted to a date. It also applies to a cell,
in which case it evaluates the contents of the cell. If the contents represent a valid date, the
function returns True . For instance, the code:
will return True if the contents of cell F3 represent a date. The IsEmpty function
This function indicates whether a variable has been initialized or whether a worksheet cell is
empty. For example, the code:
If IsEmpty(Range("A1")) Then . . .
tests whether or not cell A1 is empty. The IsNull function
This function is used to test whether a variable is Null (that is, contains no data). Note that code
such as:
If var = Null Then
will always return False because most expressions that involve Null automatically return
False . The proper way to determine if the variable var is Null is to write:
If IsNull(var) Then The IsNumeric function
Search JabSto ::

Custom Search