742
社区成员
发帖
与我相关
我的任务
分享
'Class CAnnaNode
Public Parent As CAnnaTree
Private Sub Class_Terminate()
Set Parent = Nothing
End Sub
Public Sub main()
Dim ccc As New CAnnaTree
Set ccc.Nod = Nothing
Set ccc = Nothing
End Sub
dim newfrm as form1
set newfrm = new form1
set newfrm = nothing
debug.print newfrm.name '出错,因为newfrm此时没有初始化。
dim newfrm as new form1
set newfrm = nothing '此时对象被释放
debug.print newfrm.name '因为使用了new定义对象,所以这一句代码的作用类似于set newfrm = new form1
'Module 1
Public Sub main()
' Dim ccc As New CAnnaTree
Dim ccc As CAnnaTree
Set ccc = New CAnnaTree
Set ccc = Nothing
Debug.Print ccc.TreName '这一行就会报错
Debug.Print "set nothing", Time
End Sub
'Class CAnnaTree
Public Nod As CAnnaNode
Public TreName As String
Private Sub Class_Initialize()
Set Nod = New CAnnaNode
Set Nod.Parent = Me
TreName = "throat"
End Sub
Private Sub Class_Terminate()
Debug.Print "Class_Terminate", Time
Set Nod.Parent = Nothing
End Sub
'Class CAnnaNode
Public Parent As CAnnaTree
'Module 1
Public Sub main()
Dim ccc As New CAnnaTree
' Dim ccc As CAnnaTree
' Set ccc = New CAnnaTree
Set ccc = Nothing
Debug.Print ccc.TreName
Debug.Print "set nothing", Time
End Sub
Dim ccc As New CAnnaTree
Private Sub Form_Load()
' Dim ccc As CAnnaTree
' Set ccc = New CAnnaTree
Set ccc = Nothing
Set ccc.Nod = Nothing
Debug.Print ccc.TreName
Debug.Print "set nothing", Time
End Sub