用 load 方法加载的控件,在窗体关闭时,如何释放呢?(有可能不全load)
用 load 方法加载的控件,在窗体关闭时,如何释放呢?(有可能不全load) 我动态加载控件,但是不一定一定加载,所以关闭窗体时不好判断是不是已经加载了,
所以不知如何释放资源。
Option Explicit
Private Sub cmdadd_Click()
Dim i As Integer
Dim cmdw As Integer
cmdw = cmd1(0).Width
cmd1(0).Visible = True
For i = 1 To 10
Load cmd1(i)
cmd1(i).Top = cmd1(i - 1).Top
cmd1(i).Left = cmd1(i - 1).Left + cmdw + 10
cmd1(i).Visible = True
Next
End Sub
Private Sub Form_Unload(Cancel As Integer)
'''下列代码有错误:
Dim i As Integer
' For i = 1 To 10
' Debug.Print i
' If cmd1(i) Is Nothing Then
' Debug.Print "unload"
' Unload cmd1(i)
' Else
' Debug.Print "no unload"
' End If
' Next
End Sub