Reputation: 327
I'm maintaining a vb6 project(ActiveX DLL). When debugging, the app run into the following function:
Public Function HasValue(ByVal vValue) As Boolean
On Error GoTo Err
If IsMissing(vValue) Then
HasValue = False
ElseIf IsNull(vValue) Or Len(vValue) = 0 Then
HasValue = False
ElseIf isEmpty(vValue) Then
HasValue = False
Else
HasValue = True
End If
Exit Function
Err:
If IsArray(vValue) Or IsObject(vValue) Then
HasValue = True
Else
HasValue = False
End If
End Function
and it stops at the line
ElseIf IsNull(vValue) Or Len(vValue) = 0 Then
vValue is a custom object, contains some properties(obviously, not null).
Although I didn't put any break point there, the app stopped there and alerted error dialog saying that "Run-time error '438': Object doesn't support this property or method".
We had error handling code but the app didn't run to error handling code. It just stopped at the line causing the error and I had to stop the application.
Do you have any idea about that? Thank you very much.
Upvotes: 2
Views: 1222
Reputation: 14755
As far as i know vb6 does not support boolean short evaluation in
ElseIf IsNull(vValue) Or Len(vValue) = 0 Then
so Len(vValue) = 0
is executed even if IsNull(vValue)
is true.
changing your code to
...
ElseIf IsNull(vValue) Then
HasValue = False
ElseIf Len(vValue) = 0 Then
HasValue = False
ElseIf ...
might solve the problem
Upvotes: 0
Reputation: 156
As far as getting the popup running in the debugger, it is probably related to your "Error Trapping" settings in the IDE. Go To Tools->Options->General and see what selected under "Error Trapping". At first glance it seems odd that your error handler is testing the vValue in the event of an error. It makes more sense to me based on my limited understanding of this method to move both the IsArray and IsObject conditions up into the main testing logic. Just my 2 cents :)
Upvotes: 6