Shameem Khan
New Member
- Joined
- Aug 9, 2020
- Messages
- 13
- Office Version
- 2013
- Platform
- Windows
Hello,
I have 30 textboxes in my Userform (Userform1) which are named TB11,TB12,TB13..... etc and I am using a textbox_change Sub inside a class to change the setfocus to the next textbox after any character is entered in one textbox. But for some reason, my sub inside the class is not firing when I enter a character in the textbox. Can anyone help me find what I am doing wrong ?
Thanks in Advance !
Inside the Userform1:
Inside Class1:
I have 30 textboxes in my Userform (Userform1) which are named TB11,TB12,TB13..... etc and I am using a textbox_change Sub inside a class to change the setfocus to the next textbox after any character is entered in one textbox. But for some reason, my sub inside the class is not firing when I enter a character in the textbox. Can anyone help me find what I am doing wrong ?
Thanks in Advance !
Inside the Userform1:
VBA Code:
Private Sub UserForm_Initialize()
TB11.SetFocus
Dim c As Control
Dim tb As New Class1
For Each c In Me.Controls
If TypeName(c) = "TextBox" Then
Set tb.txtbox = c
End If
Next c
End Sub
Inside Class1:
VBA Code:
Public WithEvents txtbox As MSForms.TextBox
Public Sub txtbox_Change()
Dim a As Integer
If Len(txtbox) = 1 Then
a = Right(txtbox.Name, 2) + 1
UserForm1.Controls("TB" & a).SetFocus
End If
End Sub
Last edited by a moderator: