|
本帖最后由 ndt3 于 2023-5-4 17:32 编辑
各位老师,我在窗体中动态创建了一批textbox,现在其他事件能响应,但exit事件,始终没有反应,求教各位老师!
类模块代码如下:十分感谢!
Public WithEvents txtcom As MSForms.TextBox
Public WithEvents ControlEvents As MSForms.Control
Public Property Set Control(ByVal tb As Object)
Set txtcom = tb
Set ControlEvents = tb
End Property
Public Sub init(ctl1 As MSForms.TextBox)
Set btnObj = ctl1 '过程功能:把对象参数ctl传递给btnObject变量
End Sub
Private Sub txtcom_Exit(ByVal Cancel As MSForms.ReturnBoolean) '不能运行
MsgBox txtcom.Name & "txtcom exit"
End Sub
Private Sub txtcom_LostFocus() '不能运行
MsgBox txtcom.Name & "txtcom lost"
End Sub
Private Sub txtcom_Enter() '不能运行
MsgBox "Enter your last name."
End Sub
Private Sub txtcom_Change2() '输入时工作
With UserForm2
MsgBox txtcom.Name & "change txtcom1"
End With
End Sub
Private Sub txtcom_MouseDown2(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) '可以成功运行
With UserForm2
MsgBox txtcom.Name & "down txtcom"
End With
End Sub
Private Sub txtcom_MouseUp2(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) '与down重复工作,down在前面,可以成功运行
With UserForm2
MsgBox txtcom.Text & "up txtcom"
End With
End Sub
Private Sub txtcom_gotFoucs() '不能运行
MsgBox txtcom.Text & "go txtcom"
End Sub
Private Sub ControlEvents_Enter() '不能运行
MsgBox txtcom.Text & "contr enter"
End Sub
Private Sub ControlEvents_Exit(ByVal Cancel As MSForms.ReturnBoolean) '不能运行
MsgBox txtcom.Name & "contr exit"
End Sub
在窗体中创建的textbox,exit事件可以响应.
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
MsgBox TextBox1.Text & "txt1 exit"
End Sub
|
|