How do I check for an object being Nothing in VB6?
In my VB6 application I have an array of objects declared thus...
Dim MyArray() as MyClass
This array is filled in as processing goes on
Set MyArray(element) = passed_object
and as elements are no longer wanted,
Set MyArray(otherelement) = Nothing
When using the array, I want to use a loop like
For i = 1 To Ubound(MyArray)
If MyArray(i) <> Not开发者_StackOverflow社区hing Then ' Doesn't compile
...do something...
End If
Next i
But I can't get anything likely-looking to compile. I've also tried
If MyArray(i) Is Not Nothing Then
Should I want to do this, and if so, what test should I put in here?
If Not MyArray(i) Is Nothing Then
If Not MyArray(i) Is Nothing Then
Instead of
IsNothing(<object here>)
this should work in VB6:
<object here> Is Nothing
Private Function IsNothing(objParm As Object) As Boolean
IsNothing = IIf(objParm Is Nothing, True, False)
End Function
精彩评论