Dim colEventText As New CollectionFor index = 1 To 4
Dim cnode As New clsNode
cnode.strtext = index
cnode.stateBegin = "test" colEventText.Add cnode
next 本意是循环每次生成新的cnode.但是结果都指定为同一个.
collection里面添加的都是同一个对象. 请问, Dim cnode As New clsNode不能重新生成对象吗?
调试欢乐多
For Index = 1 To 4
Dim cnode As New clsNode
cnode.strtext = Index
cnode.stateBegin = "test"
colEventText.Add cnode
Set cnode = Nothing
Next
Dim cnode As clsNode
For Index = 1 To 4
Set cnode = New clsNode
cnode.strtext = Index
cnode.stateBegin = "test"
colEventText.Add cnode
Set cnode = Nothing
Next但是如果写
Dim colEventText As New Collection
Dim cnode As new clsNode
For Index = 1 To 4
cnode.strtext = Index
cnode.stateBegin = "test"
colEventText.Add cnode
Set cnode = Nothing
Next
也可以的,按理你如果把一个ADO的对想SET NOTHING了,你不可以再用里面的对想和方法,但是这个却可以
Dim colEventText As New CollectionFor index = 1 To 4
Dim cnode As clsNode
set cnode=new clsnode
cnode.strtext = index
cnode.stateBegin = "test" colEventText.Add cnode
next
Dim cnode As New clsNode不能重新生成对象吗?