Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 214
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
CLASS MODULE & SIMPLE MODULE FARAZ QURESHI Excel Discussion (Misc queries) 1 September 7th 07 09:32 AM
Class module Mark[_36_] Excel Programming 2 February 17th 04 03:14 PM
Class module David Excel Programming 4 December 31st 03 01:58 PM
Variable from a sheet module in a class module in XL XP hglamy[_2_] Excel Programming 2 October 14th 03 05:48 PM


All times are GMT +1. The time now is 07:14 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"