View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
ed ed is offline
external usenet poster
 
Posts: 59
Default 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



.