关于对象的深拷贝问题,求思路?方法?
有一个窗口,上面有一个 CommandButton,名字为Command1 ,Caption为"123" 有代码如下
private sub CopyObject() dim cbNew as commandButton dim cbOld as commandButton set cbOld = me.Command1 debug.print cbOld.Caption '此处打印 123 set cbNew = me.Command1 cbNew.caption = me.Command1.Caption + me.Command1.Caption debug.print cbOld.Caption '此处打印 123123 end sub
Dim WithEvents cmd1 As CommandButtonPrivate Sub cmd1_Click() MsgBox "cmd1!"End SubPrivate Sub Form_Load() Set cmd1 = Me.Controls.Add("VB.CommandButton", "cmd1") With cmd1 .Visible = True .Width = 1000 .Height = 1000 .Caption = "i'm cmd1~" End WithEnd Sub