Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Flashing BackColor 2

Status
Not open for further replies.

TorrediPisa

Programmer
Apr 15, 2004
67
0
0
IT
Hello to everyone!

Have you got an idea about doing a flashing background textbox or label?
Thank You for Yr kind help.
Regards
TdP
 
Use a timer and change the .BackColor property in the timer event.

Hope this helps

HarleyQuinn
---------------------------------
Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Can You give me a little example? I am a very hard beginner!

My target is: to make a textbox or label background flash when I call a Subroutine. For Example

......
If bolAlarm = True then Call FlashText
(where FlashText contains the code I need to make the flashing of a certain textbox or label)

Can you help me?
Thanks and regards
Tdp
 
Something like (with Text23 being replaced with your textbox/label name):
Code:
If bolAlarm = True then Timer2.Enabled = True

[green]''The code for the timer event[/green]
Private Sub Timer2_Timer()
If Text23.BackColor = vbWhite Then
Text23.BackColor = vbRed
Else
Text23.BackColor = vbWhite
End If
End Sub
You can double click the timer on your form to bring up the Timer event.

You will have to set the timer's enabled property to false (and set a suitable interval property e.g. 1000 for 1 second) in the properties window so you can enable it using the code. When you want the flashing to stop simply set the .Enabled property of the timer to False.

Hope this helps

HarleyQuinn
---------------------------------
Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Private Sub Timer1_Timer()
If Label1.BackColor = vbWhite Then
Label1.BackColor = vbBlack
Else: Label1.BackColor = vbWhite
End If
End Sub



Set timer interval to desired time, and of course - you may also need to change the label1.ForeColor too depending on your choices for backcolor.
 
Add a timer control to your form and set its enabled property to False or it will always flash. You will need to set the timer interval too.
In the Timer event of the control put your flash code:

Code:
Private Sub Timer1_Timer()
   Static blnFlash As Boolean
   If blnFlash Then
      Label1.BackColor = vbRed
   Else
      Label1.BackColor = vbButtonFace
   End If
   blnFlash = Not blnFlash
End Sub

Then just enable the timer from you code to make it flash:

Code:
If bolAlarm = True then Timer1.Enabled = True
 
If anyone is interested, I made a simple control that can be used to flash the background of just about any other control. It allows you to set the color, the frequency, and the number of times it flashes before it stops.

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Hi all:

I noticed that something was not mentioned that should have been.

One needs to avoid flash rates in the 3 - 10 flashes per second range.

Users who have epilepsy are usually sensitive to visual stimuli in this range. We would not want to trigger seizures, would we?





Cassie
PIII-500Mhz-128MB
Win98SE-VB6SP5
 
Many years ago, I was watching a movie in a theater. There was a sequence at the beginning that runs credits on an alternating blue and orange (or something like it) background, and in the range mentioned above. Some poor kid had a major epileptic seizure (split his forehead open on the seat in front of him in fact) a couple of seats away from me and I had to give him first aid.

So, I second Cassandra's post, and provide this (true) story to emphazise that it is to be taken very seriously.

Bob
 
Is there any study on how many flashes, or how long, it takes to cause a seizure? When I flash the background of a control to signal an error I only flash it two or three times, then stop.

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Oh, for goodness sake everyone. Stop overreacting to the very minor risk of photoepileptics responding adversely to a flashing control





 
I'm not overreacting, just curious. I have no intention of going back and changing what I did regardless. I like the way it works now.

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Sorry. Not you specifically. The thread as a whole. Starting with:

>Users who have epilepsy are usually sensitive to visual stimuli in this range

Photosensitive epilpetics only make up about 5% of the epileptic population

That 5% are mostly suceptible in the 15 - 20Hz range

And normally the whole screen to be flickering at this frequency because we need to fill the field of vision before there is likely to be any affect.

One itty bitty control flashing at whatever rate you like isn't going to hurt anyone
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top