动态加载控件后,事件代码怎么办?

来源:百度知道 编辑:UC知道 时间:2024/05/15 07:28:53
加载了控件后,没有可以触发事件的代码.例如我加左了一个command1(0)控制,但是command1(0)_click的事件怎么办?怎么样使command1(0)变为可以执行代码的控件

加载时设置控件的Tag属性
Load Command1(1)
Command1(1).Tag = "Word.exe"

Private Sub Command1_Click(Index As Integer)
shell Command1(Index).Tag
end if

数组控件嘅单击事件问题,用番Select Case语句
Private Sub Command1_Click(Index As Integer)
Select Case Index
Case 0
'command1(0)要执行的代码
Case 1
'command1(1)要执行的代码
End Select
End Sub

Dim WithEvents Command1(1) As VB.CommandButton
声明的时候加上withevents,就可以用他的属性和方法了