Hi,
Is the code exactly the same for each control? I assume the text check is comparing the text with the name of the control.
You might use an approach like this
Private Sub Title_Enter()
EntryFormat Title
End Sub
Private Sub Title_Exit(ByVal Cancel As MSForms.ReturnBoolean)
ExitFormat Title
End Sub
Sub EntryFormat(ctl As MSForms.Control)
If LCase$(ctl.Text) = LCase$(ctl.Name) Then
ctl.Text = ""
ctl.BackColor = RGB(255, 255, 153)
End If
End Sub
Sub ExitFormat(ctl As MSForms.Control)
If Trim(ctl.Text) = "" Then
ctl.Text = ctl.Name
ctl.BackColor = RGB(255, 255, 255)
End If
End Sub
It is possible to implement handlers for the Enter and Exit events with a class but it is not at all trivial.
Bookmarks