看到yachong在一个帖子回了一段有意思的,转贴在这里:
很多时候给属性赋值会触发事件,至于哪个属性触发哪个事件就要靠经验了:)
Private Sub Command1_Click() ''这三个属性会触发下面的三个事件 Option1.Value = True Text1.Text = "12345" List1.ListIndex = 1 End Sub Private Sub List1_Click() Debug.Print "List1_Click" End Sub Private Sub Option1_Click() Debug.Print "Option1_Click" End Sub Private Sub Text1_Change() Debug.Print "Text1_Change" End Sub 程序简单并且对性能要求不高的时候,我就用下面的办法
Private Sub Command1_Click() '每个控件都有tag属性 '使用tag属性比使用全局变量方便 Option1.Tag = "啥也别干" Option1.Value = True Text1.Tag = "啥也别干" Text1.Text = "12345" List1.Tag = "啥也别干" List1.ListIndex = 1 End Sub Private Sub List1_Click() If List1.Tag = "啥也别干" Then List1.Tag = "" Exit Sub End If Debug.Print "List1_Click" End Sub Private Sub Option1_Click() If Option1.Tag = "啥也别干" Then Option1.Tag = "" Exit Sub End If Debug.Print "Option1_Click" End Sub Private Sub Text1_Change() If Text1.Tag = "啥也别干" Then Text1.Tag = "" Exit Sub End If Debug.Print "Text1_Change" End Sub