Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
using class module
my userform has a lot of textboxes. i want to change backcolor with yellow in is focused a textbox using class module. *** Sent via Developersdex http://www.developersdex.com *** |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
using class module
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 "tom taol" a écrit dans le message de news: ... my userform has a lot of textboxes. i want to change backcolor with yellow in is focused a textbox using class module. *** Sent via Developersdex http://www.developersdex.com *** |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
CLASS MODULE & SIMPLE MODULE | Excel Discussion (Misc queries) | |||
Class module | Excel Programming | |||
Class module | Excel Programming | |||
Variable from a sheet module in a class module in XL XP | Excel Programming |