473,508 Members | 2,382 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Making label control flash

doma23
107 New Member
Hi,
I have a label control lblLocked, and 5 comboboxes.
These comboboxes serve as a search functions by limiting values in each other based on user's selection.
On each combobox there is an After Update event set which checks if ListCount property on each of these combobxes equals to 1.
If the condition is true, than I want lblLocked which is by defualt invisible to flash 2-3 times and then stop, just making it visible.
How can I do this?

I've been searching on the internet and I've ran on TimeInterval property and On Timer event, and although I was trying something, I couldn't figure it out how they can help me, as the code on form's On Timer event code is being executed constantly, based on Time Interval property.

This is basically the algorithm that I need:

Expand|Select|Wrap|Line Numbers
  1. If Form_frmMain.cbo1.ListCount = 1 and Form_frmmain.cbo2.ListCount = 1 and.... Then
  2. HOLD NEXT LINE FOR ONE SECOND
  3. Form_frmMain.TimerInterval = 200
  4. AFTER ONE SECOND DO THIS
  5. Form_frmMain.TimerInterval = 0
  6. Form_frmMain.lblLocked.Visible = True
  7. End If
  8.  
Tnx!
Sep 16 '10 #1
7 4859
munkee
374 Contributor
I am not too farmiliar with using timers etc so I usually just revert to creating loops. Not elegant but you will see how it runs.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command74_Click()
  2. Dim currenttime As Date
  3. currenttime = Now()
  4. Do
  5. Loop While Now() < currenttime + TimeSerial(0, 0, 5)
  6. MsgBox "5 seconds done"
  7. End Sub
  8.  
Sep 16 '10 #2
doma23
107 New Member
Unfortunately, it doesn't help. I cannot get it to work.
I've put multiple do loop while statements, with 1 second timeserial, and with the vba statements "lblLocked.Visible=True" in one and then "lblLocked.Visible=True" in next.
Although it's not satisfying solution, I just wanted to test it, and it didn't work.
Sep 16 '10 #3
Megalog
378 Recognized Expert Contributor
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Public lngCount As Long
  5.  
  6. 'The AfterUpdate events from whatever control you 
  7. 'want this to activate on. Duplicate this for each 
  8. 'combo/list control
  9.  
  10. Private Sub cbo1_AfterUpdate()
  11.     Call CheckLists
  12. End Sub
  13.  
  14. Private Sub cbo2_AfterUpdate()
  15.     Call CheckLists
  16. End Sub
  17.  
  18.  
  19. Private Sub CheckLists()
  20. 'This checks the criteria (Listcounts) and 
  21. 'sets the timer off if it matches, otherwise 
  22. 'hides the possibly visible label.
  23.  
  24.     lngCount = 0
  25.     If Form_frmMain.cbo1.ListCount = 1 and Form_frmmain.cbo2.ListCount = 1 and.... Then
  26.         Me.TimerInterval = 250
  27.     Else
  28.         Me.lblLocked.Visible = False
  29.     End If
  30.  
  31. End Sub
  32.  
  33. Private Sub Form_Timer()
  34. 'Timer event itself.  Flashes on and off 6 times,
  35. 'then turns the interval off and leaves the label visible.
  36.  
  37.     If lngCount < 6 Then
  38.         Me.lblLocked.Visible = Not Me.lblLocked.Visible
  39.         lngCount = lngCount + 1
  40.     Else
  41.         Me.lblLocked.Visible = True
  42.         Me.TimerInterval = 0
  43.     End If
  44.  
  45. End Sub
Sep 16 '10 #4
doma23
107 New Member
@Megalog

Haha. It works a charm! Beautiful. Tnx!
I wasn't able to find the solution on internet for this at all. There were people asking the same question, but nobody provided even direction to the solution.
I believe the bytes forum might be the first. :)
I knew that there needs to be something with setting TimerInterval to zero, but didn't know how to make the logical sequence.
Even after I saw your code, it took me a bit to understand how it works. I was confused as there was no loop for counting, and then I realized that the loop is basically 250ms of Timer itself.

The only thing is that it doesn't flash 6 times, maybe only 3 times. I think it has to do something with this line:
me.lbllocked.visible = not me.lbllocked.visible

I don't fully understand it.
Sep 17 '10 #5
Megalog
378 Recognized Expert Contributor
The timer handles the frequency of the event. The lngCount value determines what happens in the event.

This line simply toggles the .Visible property by assigning it's opposite value to it:

Expand|Select|Wrap|Line Numbers
  1. Me.lblLocked.Visible = Not Me.lblLocked.Visible 
If you want it to flash more, then the first line can be increased to a higher number like:
Expand|Select|Wrap|Line Numbers
  1. If lngCount < 12 Then 
Everytime the lists get checked, lngCount gets reset to zero and it all starts over again.
Sep 17 '10 #6
doma23
107 New Member
This line simply toggles the .Visible property by assigning it's opposite value to it
Yes, I never seen the syntax before and I thought that it should work the same as "me.lblLocked.visible = False" and that was confusing me.
Now it's perfectly clear.

If you want it to flash more, then the first line can be increased to a higher number like
Yeah, I just didn't understand why it doesn't flashes the number of times indicated, but basically twice less. So if you set lngcount < 10 it will flash 5 times, if it's set to 8 or 9 it will flash 4 times. Now, it's clear - because of the toggle effect:
0 - visible
1 - invisible
2 - visible
3 - invisible
4 - visible
and so on...
Sep 17 '10 #7
Megalog
378 Recognized Expert Contributor
0 - visible
1 - invisible
2 - visible
3 - invisible
4 - visible
Exactly how it works. "Me.lblLocked.Visible = Not Me.lblLocked.Visible" works by taking the current .visible value and applying the opposite. Thus each time the timer event activates it is toggling it on and off for as many times as it's allowed before it permanently stays visible.
Sep 17 '10 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
3985
by: John Bowman | last post by:
Hello, I need to concatonate 2 strings and insert padding spaces in between them. The number of padding spaces needs to be calculated such that I can place the entire resultant string into a...
4
5864
by: Mystery Man | last post by:
I want to deliberately make a label (and perhaps a button) flash to alert the user that something very serious has happened. Any ideas on how to do this?
7
2900
by: Mike Casey | last post by:
Hello all, I have ASP.NET label controls tied to a datasource (so text will vary in length depending on the record). In IE everything looks great--text is wrapped if needed. In Netscape and...
7
1284
by: Grigs | last post by:
I was able to do this in .asp but not asp.net, can someone please help. I have a multi-line textbox control on a webform. Next to it is a label control. Basically I want the label control to...
3
6617
by: PK9 | last post by:
I'm having some issues with using a Response.Write or the shortcut ( <%= ...) from within a label control. I cannot do this in the code behind, I need to do it here at runtime. I have a public...
6
3132
by: jcrouse | last post by:
I am rotating some text is some label controls. In the one place I use it it works fine. In the other place I use it I can't figure out the syntax. I don't really understand the event. Where it...
4
5147
by: cashdeskmac | last post by:
I want to justify the text in a label control so that all of the text fills the label equally, but there don't seem to be any properties to set to allow this. Can anyone help?
1
3868
by: | last post by:
I have a label control that I've embedded in a datalist template. I will be binding data to that label. I want to run a string formatting function on the database text before it is injected into...
8
1912
by: Arpan | last post by:
Consider the following code snippet (my main intention is to display the current time in a Label control as & when this ASPX page is accessed/refreshed): <script runat="server"> Class Clock...
5
11741
by: BobLaughland | last post by:
Hi There, I am trying to get some fields to align on a web page, like this, To: From: Subject: Each of the fields above have a corresponding asp:Textbox control next to it that I cannot...
0
7377
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7036
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7489
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...
0
5624
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,...
0
4705
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...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1547
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 ...
0
414
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...

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.