I have an object and within it I wanna check if some properties is set to false, like:
If (not objresult.EOF) Then 'Some code End if
But somehow, sometimes objresult.EOF
is Empty
, and how can I check it?
IsEmpty
function is for excel cells onlyobjresult.EOF Is Nothing
- return Empty
objresult.EOF <> null
- return Empty
as well!The ISEMPTY function returns TRUE if the value is a blank cell or uninitialized variable. The ISEMPTY function returns FALSE if the value is a cell or variable that contains a value (ie: is not empty).
The Null value indicates that the Variant contains no valid data. Null is not the same as Empty, which indicates that a variable has not yet been initialized. It's also not the same as a zero-length string (""), which is sometimes referred to as a null string.
VBA IsEmpty is a logical function that tests whether selected is empty or not. Since it is a logical function it will return the results in Boolean values i.e. either TRUE or FALSE. If the selected cell is empty it will return TRUE or else it will return FALSE.
The VBA InStr function is one of the most useful string manipulation functions around. You can use it to test if a string, cell or range contains the substring you want to find. If it does, “InStr” will return the position in the text string where your substring begins.
How you test depends on the Property's DataType:
| Type | Test | Test2 | Numeric (Long, Integer, Double etc.) | If obj.Property = 0 Then | | Boolen (True/False) | If Not obj.Property Then | If obj.Property = False Then | Object | If obj.Property Is Nothing Then | | String | If obj.Property = "" Then | If LenB(obj.Property) = 0 Then | Variant | If obj.Property = Empty Then |
You can tell the DataType by pressing F2 to launch the Object Browser and looking up the Object. Another way would be to just use the TypeName function:MsgBox TypeName(obj.Property)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With