Solved

Make label flash with different Background colors

Posted on 2000-05-12
4
1,302 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
mcmonniesa earned 50 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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

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.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

636 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