473,378 Members | 1,314 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

using timers to flash label messages

is there a simple way to code a timer to make a warning label blink on and off?
Lets say I have a form with 3 textboxes and 4 labels plus one timer
object(labelTimer)and 2 buttons(start,stop).labels 1,2 and 3 are attached to
textboxes 1,2 and 3. label 4 is stand alone and needs to bink a warning while
calculations are being made(startButton click to stopButton click).The
interval should be 1/2 sec.
for instance: "Calculating Results" blinks at 1/2 sec intervals until the
stop button is clicked then "Calculations Complete" and visible = true when
the stop button is clicked.
I posted another question a few days ago concerning timespan structures and
you guys came through so maybe some guru can help the wannabe out here too?
thanks guys
Nov 21 '05 #1
1 2042
Here is a flash routine I wrote a few months ago. This won't work as
is. It is part of a rather complicated UserControl, but you can see how
the concept works. (The refresh method that this calls is what actually
changes the colors of the label based on the myLabelForeColor value.)
#Region "Flash"

Private myFlashTime As Long
Private Flasher As System.Threading.Timer
Private HoldForeColor As Color

Private myFlashWaitTime As Long = 0
Public Property FlashWaitTime() As Long
Get
Return myFlashWaitTime
End Get
Set(ByVal Value As Long)
myFlashWaitTime = Value
End Set
End Property

Private myFlashOnTime As Long = 500
Public Property FlashOnTime() As Long
Get
Return myFlashOnTime
End Get
Set(ByVal Value As Long)
myFlashOnTime = Value
End Set
End Property

Private myFlashOffTime As Long = 100
Public Property FlashOffTime() As Long
Get
Return myFlashOffTime
End Get
Set(ByVal Value As Long)
myFlashOffTime = Value
End Set
End Property

Public Sub StartFlashing()
If myFlashOnTime = 0 Or myFlashOffTime = 0 Then Exit Sub
myFlashTime = myFlashOnTime
HoldForeColor = myLabelForeColor
Flasher = New System.Threading.Timer(AddressOf Flash, Nothing,
myFlashWaitTime, myFlashOnTime)
End Sub

Public Sub StopFlashing()
If Flasher Is Nothing Then Exit Sub
Flasher.Change(System.Threading.Timeout.Infinite, 0)
Flasher = Nothing
Me.myLabelForeColor = HoldForeColor
Refresh()
End Sub

Private Sub Flash(ByVal state As Object)

'state = Nothing
If Me.FindForm Is Nothing Or Me.Parent Is Nothing Or Me Is
Nothing Or Flasher Is Nothing Then
StopFlashing()
Exit Sub
End If

If myLabelForeColor.Equals(myLabelBackColor) Then
myLabelForeColor = HoldForeColor
Else
myLabelForeColor = myLabelBackColor
End If

Refresh()

If myFlashTime = myFlashOffTime Then
myFlashTime = myFlashOnTime
If Not Flasher Is Nothing Then Flasher.Change(myFlashTime,
myFlashOffTime)
Else
myFlashTime = myFlashOffTime
If Not Flasher Is Nothing Then Flasher.Change(myFlashTime,
myFlashOnTime)
End If

End Sub

#End Region 'Flash

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Andrew Gordon | last post by:
I'm investigating getting Microsoft Navision to do stuff from a Python script. The recommended way seems to be to use message queues (MSMQ). I can get Navision to send a message to itself fine. I...
3
by: Jeff Greenland | last post by:
Hello everyone, I am having problems with Timers in a web application. They just seem to stop running after 15 minutes or so. My web application is set up like this: When a user hits a...
2
by: User | last post by:
Hi, What is the best way to release all resources holded by the Timer (myTimer from class System.Timers.Timer)? Is it: 1- myTimer.dispose 2- myTimer.enabled = false 3- myTimer.close
6
by: ransoma22 | last post by:
I developing an application that receive SMS from a connected GSM handphone, e.g Siemens M55, Nokia 6230,etc through the data cable. The application(VB.NET) will receive the SMS automatically,...
13
by: Susan Beebe | last post by:
I have downloaded the code described in Microsoft article Q154078. I am trying to send raw ZPL (zebra barcode printer) code from Microsoft access. It works just fine if I hard code the actual...
3
by: ginguene | last post by:
Its supposed to be a very simple program, with a class to display the updated current time every second (CAnalogTime) inside a Label in my form, using ElapsedEventHandler from System.Timers; The...
2
by: janama | last post by:
Hi all, Using wx When adding a second timer as i have the first, the second timer adding stops the first timer (updating or stops?) . In this example im updating a uptime and localtime label....
2
by: j1808 | last post by:
hi there, so yes, im am trying to make my label flash diffrent colours, so when i have enterd a value in some textbox which does not meet my parameter, (i.e runs the ELSE in an IF..) it runs this...
3
by: plongo01 | last post by:
Form some reason I cannot get the flash form to align in the center of the page. Here is my code: <cfform format="flash" skin="haloblue"> <cfformgroup type="vertical"...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.