In the attached workbook is an attempt to enforce formatting to certain textbox entries in a multipage userform. The reason for this class module approach is that this is the groundwork to apply to a much larger application when sorted.
I have control of the formatting of the textboxes I require by way of choosing to set a array in the class module.
On multipage1 first and last textbox has no entry restriction - 2 and 3 are set to a date format "dd mm yyyy"
I wanted to add an exit event that requires the text length to be a minimum 10 digits
In the bottom right corner I have a test textbox that behaves as I wish it to by way of
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
With TextBox1
If TextBox1.Text = "" Then Exit Sub
If Len(TextBox1.Text) < 10 Then
.Tag = ""
.SelStart = 0
.SelLength = Len(.Text)
MsgBox "Please Enter Date in dd mm yyyy format"
Cancel = True
Else: Exit Sub
End If
End With
End Sub
I would like to have this format for all the textboxes declared in the array but it is failing me as to where to place or how to code it. I have tried replacing
with
as I have used elsewhere but to no avail. Any pointers appreciated
Bookmarks