473,788 Members | 2,837 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(labelTim er)and 2 buttons(start,s top).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(startButto n click to stopButton click).The
interval should be 1/2 sec.
for instance: "Calculatin g Results" blinks at 1/2 sec intervals until the
stop button is clicked then "Calculatio ns 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 2060
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 myLabelForeColo r value.)
#Region "Flash"

Private myFlashTime As Long
Private Flasher As System.Threadin g.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 = myLabelForeColo r
Flasher = New System.Threadin g.Timer(Address Of Flash, Nothing,
myFlashWaitTime , myFlashOnTime)
End Sub

Public Sub StopFlashing()
If Flasher Is Nothing Then Exit Sub
Flasher.Change( System.Threadin g.Timeout.Infin ite, 0)
Flasher = Nothing
Me.myLabelForeC olor = 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 myLabelForeColo r.Equals(myLabe lBackColor) Then
myLabelForeColo r = HoldForeColor
Else
myLabelForeColo r = myLabelBackColo r
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
3725
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 found a couple of code example in an ancient message in this newsgroup. The send.py one I changed to the following: from win32com.client import gencache msmq = gencache.EnsureModule('{D7D6E071-DCCD-11D0-AA4B-0060970DEBAE}', 0, 1, 0) qi =...
3
2039
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 page in the site, that page (.aspx) instantiates a compiled class (.DLL). The instantiation process creates a Timer that runs in the background to perform tasks every so often (such as notifying clients
2
9050
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
17206
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, process and output to the screen in my application when a message arrived. But the problem is how do I read the SMS message immediately when it arrived without my handphone BeEPINg for new message ? I read up the AT commands, but when getting down...
13
21699
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 data in the string being sent to the printer. However, if I prompt the user for data or if I insert data from a particular record/field in a form Access crashes/closes on its own. I have included the code below, if anyone has any suggestions,...
3
5439
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 event is working, because the displaybox will show up every second like requested. Although the label (which i was able to initialize with a value), wont update itself in this event. Any ideas?
2
4691
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. It works fine for displaying the last "self.startTimer2()" called. But prevents the previous self.startTimer1() from running . Im doing something fundamentally wrong i guess?
2
7602
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 code so it flashes the label red -->white --> red --> white so it simply flash'es the code. my code is MsgBox("flashing --> start") 'test1 lblSnK.ForeColor = Color.Red System.Threading.Thread.Sleep(10000) 'pauses...
3
4929
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" style="vertical-align:center"> <cfinput type="text" name="test1" id="test1" label="Testing:" size="25" /> <cfinput type="text" name="test2" id="test2" label="test2" size="25" /> </cfformgroup> </cfform> I have also tried:
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9969
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5536
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4070
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3675
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.