For i = 0 To MainMem.BNumber - 1
   If BlockShape(i) Is Nothing Then
      Load BlockShape(i)
   End If
   BlockShape(i).Container = MemPicture
   If MainMem.GetMem(i).state Then
     BlockShape(i).FillStyle = 4
   Else
     BlockShape(i).FillStyle = 1
   End If
   BlockShape(i).Move 240, 360 + MainMem.GetMem(i).BeginAddress / AllMem * 6735, 975, MainMem.GetMem(i).big / AllMem * 6735
   BlockShape(i).Visible = True
Next i我这段代码中有动态添加对象blockshape,已经有了个index设置为0的blockshape,为什么一运行就提示我控件数组元素"1"不存在?是不是BlockShape(i) Is Nothing这种判断不能判断对象是空?

解决方案 »

  1.   

    关闭错误侦测即可
    On error resume next
    For i = 0 To MainMem.BNumber - 1
       Load BlockShape(i)
       BlockShape(i).Container = MemPicture
       If MainMem.GetMem(i).state Then
         BlockShape(i).FillStyle = 4
       Else
         BlockShape(i).FillStyle = 1
       End If
       BlockShape(i).Move 240, 360 + MainMem.GetMem(i).BeginAddress / AllMem * 6735, 975, MainMem.GetMem(i).big / AllMem * 6735
       BlockShape(i).Visible = True
    Next i
      

  2.   

    楼主试试这个:
    Private Sub Command1_Click()
    On Error Resume Next
        Dim i As Integer
        
        For i = 1 To 3
            Load BlockShape(i)
            Set BlockShape(i).Container = MemPicture
            
            ...
            BlockShape(i).Move 240, 360 + i * 1000, 975
            BlockShape(i).Visible = True
        Next i
    End Sub
      

  3.   

    还是不行,好象是container用法问题,我另外讨论好了