vbaprogammer
Programmer
I have created the following to reuse my code for textboxes by creating a class to handle the enter and exit events.
I can get the change event and several others after running this code, but what happened to the enter and exit? I really do need the enter and exit events.
This code is placed in my Form:
Dim cTB1 As CTextBox
Dim cTB2 As CTextBox
Private Sub UserForm_Initialize()
Set cTB1 = New CTextBox
Set cTB2 = New CTextBox
Set cTB1.Control = Me!TextBox1
Set cTB2.Control = Me!TextBox2
End Sub
This code is placed in my CTextBox class:
Public WithEvents mTextBox As TextBox
Public Property Set Control(ByVal ctlNewControl As TextBox)
Set mTextBox = ctlNewControl
End Property
Private Sub mTextBox_Change()
MsgBox "You're in the Change event of the CTextBox class."
End Sub
============
Thanks,
Dan
I can get the change event and several others after running this code, but what happened to the enter and exit? I really do need the enter and exit events.
This code is placed in my Form:
Dim cTB1 As CTextBox
Dim cTB2 As CTextBox
Private Sub UserForm_Initialize()
Set cTB1 = New CTextBox
Set cTB2 = New CTextBox
Set cTB1.Control = Me!TextBox1
Set cTB2.Control = Me!TextBox2
End Sub
This code is placed in my CTextBox class:
Public WithEvents mTextBox As TextBox
Public Property Set Control(ByVal ctlNewControl As TextBox)
Set mTextBox = ctlNewControl
End Property
Private Sub mTextBox_Change()
MsgBox "You're in the Change event of the CTextBox class."
End Sub
============
Thanks,
Dan