如何在VB6中检查对象是否为Nothing?

Bri*_*per 16 vb6

在我的VB6应用程序中,我有一个声明的对象数组...

Dim MyArray() as MyClass
Run Code Online (Sandbox Code Playgroud)

随着处理的进行,该数组被填充

Set MyArray(element) = passed_object
Run Code Online (Sandbox Code Playgroud)

并且因为不再需要元素,

Set MyArray(otherelement) = Nothing
Run Code Online (Sandbox Code Playgroud)

使用数组时,我想使用类似的循环

For i = 1 To Ubound(MyArray)
    If MyArray(i) <> Nothing Then    ' Doesn't compile
        ...do something...
    End If
Next i
Run Code Online (Sandbox Code Playgroud)

但我无法得到任何可能 - 想要编译.我也试过了

If MyArray(i) Is Not Nothing Then
Run Code Online (Sandbox Code Playgroud)

我是否应该这样做,如果是这样,我应该在这里进行什么测试?

mwo*_*e02 35

If Not MyArray(i) Is Nothing Then
Run Code Online (Sandbox Code Playgroud)


Aak*_*shM 15

If Not MyArray(i) Is Nothing Then
Run Code Online (Sandbox Code Playgroud)