Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Userform blinking label
I have a userform with two labels and one button. I
would like to alternate the label backcolors between red and white. ie label1 backcolor is white, label2 red pause label1 backcolor is red, label2 white and so forth. Code in standard modual: (Adapted from an old post) Blink is called from buttons click event. Code works if I step through but does not work if breaks are removed. I'm stumped. TIA for any assistance Ed Option Explicit Private Declare Function GetComputerName Lib "kernel32" _ Alias "GetComputerNameA" (ByVal lbbuffer As String, _ nsize As Long) As Long Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Public Sub Blink() Dim mytime As String Dim i As Long For i = 1 To 50 ' set one color UserForm1.Label1.BackColor = &HFFFFFF UserForm1.Label2.BackColor = &HFF& Call Sleep(60) UserForm1.Label1.BackColor = &HFF& UserForm1.Label2.BackColor = &HFFFFFF Call Sleep(60) Next i End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Userform blinking label
Ed,
Place the following statement before each call of Sleep. DoEvents This releases control to the operating system to update the screen. You can also use UserForm1.RePaint John Green "Ed" wrote in message ... I have a userform with two labels and one button. I would like to alternate the label backcolors between red and white. ie label1 backcolor is white, label2 red pause label1 backcolor is red, label2 white and so forth. Code in standard modual: (Adapted from an old post) Blink is called from buttons click event. Code works if I step through but does not work if breaks are removed. I'm stumped. TIA for any assistance Ed Option Explicit Private Declare Function GetComputerName Lib "kernel32" _ Alias "GetComputerNameA" (ByVal lbbuffer As String, _ nsize As Long) As Long Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Public Sub Blink() Dim mytime As String Dim i As Long For i = 1 To 50 ' set one color UserForm1.Label1.BackColor = &HFFFFFF UserForm1.Label2.BackColor = &HFF& Call Sleep(60) UserForm1.Label1.BackColor = &HFF& UserForm1.Label2.BackColor = &HFFFFFF Call Sleep(60) Next i End Sub |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Userform blinking label
Thank you John,
Works like a charm. Ed -----Original Message----- Ed, Place the following statement before each call of Sleep. DoEvents This releases control to the operating system to update the screen. You can also use UserForm1.RePaint John Green "Ed" wrote in message ... I have a userform with two labels and one button. I would like to alternate the label backcolors between red and white. ie label1 backcolor is white, label2 red pause label1 backcolor is red, label2 white and so forth. Code in standard modual: (Adapted from an old post) Blink is called from buttons click event. Code works if I step through but does not work if breaks are removed. I'm stumped. TIA for any assistance Ed Option Explicit Private Declare Function GetComputerName Lib "kernel32" _ Alias "GetComputerNameA" (ByVal lbbuffer As String, _ nsize As Long) As Long Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Public Sub Blink() Dim mytime As String Dim i As Long For i = 1 To 50 ' set one color UserForm1.Label1.BackColor = &HFFFFFF UserForm1.Label2.BackColor = &HFF& Call Sleep(60) UserForm1.Label1.BackColor = &HFF& UserForm1.Label2.BackColor = &HFFFFFF Call Sleep(60) Next i End Sub . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Userform Label | Excel Discussion (Misc queries) | |||
Blinking Label | Excel Programming | |||
Blinking Label | Excel Programming | |||
UserForm label doesn't load? | Excel Programming | |||
UserForm Label & Format Problems | Excel Programming |