Hi Tom,
I do not think that it is possible with a module of class. To do that, a
timer is needed; a trick of the kind:
In a standard module:
Option Explicit
Private Declare Function SetTimer Lib "user32" _
(ByVal hwnd As Long, ByVal nIDEvent As Long _
, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Private Declare Function KillTimer Lib "user32" _
(ByVal hwnd As Long, ByVal nIDEvent As Long) As Long
Private iTimer As Long
Sub TimerStop(Optional dummy As Byte = 0)
If iTimer Then KillTimer 0&, iTimer
iTimer = 0
End Sub
Sub TimerStart(iVal&)
If iTimer Then TimerStop
iTimer = SetTimer(0&, 0&, ByVal iVal, AddressOf TimerProc)
End Sub
Private Sub TimerProc(ByVal lHwnd&, ByVal lMsg&, ByVal lIDEvent&, ByVal
lTime&)
On Error GoTo 1
Dim Ctl As Control
For Each Ctl In UserForm1.Controls
If Left$(Ctl.Name, 7) = "TextBox" Then
If Ctl.Name = UserForm1.ActiveControl.Name Then
Ctl.BackColor = &HFFFF&
Else
Ctl.BackColor = &H80000005
End If
End If
Next Ctl
Exit Sub
1: TimerStop
MsgBox Err.Number & vbLf & Err.Description, 48
End Sub
In UserForm module:
Private Sub UserForm_Initialize()
Me.TextBox1.SetFocus
TimerStart 250
End Sub
Private Sub UserForm_QueryClose(Cancel%, CloseMode%)
TimerStop
End Sub
Regards,
MP