窗口的enter事件写代码处理。
Select Case e.sender.name
case "treeview1", "Table1"
vars("当前控件") = e.sender.name
End Select
按钮代码
If vars("当前控件").name = "TreeView1" then
msgbox(1)
elseIf vars("当前控件").name = "Table1" then
msgbox(2)
End If