有没有办法在运行时为控件添加事件处理程序?
注意这段代码(我只有TextBox1的形式):
Option Compare Database
Option Explicit
Dim WithEvents tb As Access.TextBox
Private Sub Form_Load()
set tb = TextBox1
End Sub
Private Sub tb_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Debug.Print "tb_MouseDown"
End Sub
Private Sub TextBox1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Debug.Print "TextBox1_MouseDown"
End Sub
使用该代码,将调用两个处理程序 如果我删除处理程序TextBox1_MouseDown,则不会触发tb_MouseDown。