Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Make label flash with different Background colors

Posted on 2000-05-12
4
Medium Priority
?
1,309 Views
Last Modified: 2008-02-01
How is it possible to make a label background color change from one color to another creating a flashing effect on a form ? Do you use the form timer event, loop functions or what...

Thank you
0
Comment
Question by:fouchev
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
mcmonniesa earned 150 total points
ID: 2806169
Start by setting the label's "Back Style" to "Normal".  Next set the form's timer interval to a value (i.e., 1000 = 1 second, 100 = 1/10th of a second).  Then add code to the Form_Timer event like:

Private Sub Form_Timer()

   If lblFlasher.BackColor = vbRed Then
      lblFlasher.BackColor = vbBlue
   Else
      lblFlasher.BackColor = vbRed
   End If
   
End Sub

This sample should flash red and blue.  You can expand it to more colors or use an array of colors.
0
 
LVL 1

Expert Comment

by:mcmonniesa
ID: 2806174
Additionally the Form_Timer event acts like a continuous loop.  That is every time the interval hits (times out) the code is run.  To stop the timer, close the form or set it off in code:

    Me.TimerInterval = 0

0
 
LVL 9

Expert Comment

by:BrianWren
ID: 2806177
Option Explicit

Dim FlashState As Boolean

Private Sub Form_Timer()

       FlashState = Not FlashState

       If FlashState = True Then
              Me!ctrl.BackColor = 255      ' Red
       Else
              Me!ctrl.BackColor = 65535  ' Yellow
       End If

End Sub  

Then set the Timer interval to what you like.

To trun off the flashing, set Timer interval = 0

Brian
0
 
LVL 4

Expert Comment

by:mberumen
ID: 2806186
you could also expand fouchev's code to occur whenever a condition is meet in your database... such as an error or update..

function sub flashlabel()
for counter=1 to 100 step 10

                         If lblFlasher.BackColor = vbRed Then
                            lblFlasher.BackColor = vbBlue
                         Else
                            lblFlasher.BackColor = vbRed
                         End If
next
                         
End Sub

'then  you could call the function as needed
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question