Private WithEvents NewButton As CommandButton
Private Sub Command1_Click()
If NewButton Is Nothing Then
Set NewButton = Controls.Add("vb.commandbutton", "button1", Form1)
NewButton.Visible = True
NewButton.Caption = "button1"
End If
End Sub
Private Sub NewButton_Click()
Set NewButton = Controls.Add("vb.commandbutton", "button2", Form1)
NewButton.Visible = True
NewButton.Caption = "button2"
End Sub
.net很容易做到,VB6还是用控件数组比较好,每次创建的时候指定Index属性
然后创建的click事件参数不一样
Private Sub Command1_Click()
Private Sub Command1_Click(Index As Integer) ------解决思路----------------------