scaning progress bar

rob.low

Access Nutter
Local time
Today, 15:09
Joined
Dec 27, 2007
Messages
96
Hi all :)

What i am trying to achieve is this.

i have 3 colored labels next to each other i am trying to use the timer function to somehow make each label visible at a time
say left one visible then not, then middle visible then not, and right visible then not

Trying to get sort of a knight rider scanner effect (scan left to right then right to left)

Any ideas or help with this would be appreciated.

Thanks
Rob :)
 
You'll need some way of keeping track of which direction the thing is going - you could do this with a public variable (because it needs to persist outside of the sub), but if you're not using it for anything else, you could just use the Tag property of one of the labels, so, something like:

Code:
Private Sub Form_Timer()
Dim strTemp As String

strTemp = Trim(Me.Label0.Tag)
If (strTemp = "" Or strTemp = "5") Then strTemp = "1"
Select Case strTemp
Case Is = "1"
Me.Label0.ForeColor = vbRed
Me.Label1.ForeColor = vbBlack
Me.Label2.ForeColor = vbBlack
Case Is = "2", "4"
Me.Label0.ForeColor = vbBlack
Me.Label1.ForeColor = vbRed
Me.Label2.ForeColor = vbBlack
Case Is = "3"
Me.Label0.ForeColor = vbBlack
Me.Label1.ForeColor = vbBlack
Me.Label2.ForeColor = vbRed
End Select
Me.Repaint
Me.Label0.Tag = Str(Val(strTemp) + 1)
 
End Sub


You should be aware, however that:
-It might not appear to be working if the processor gets tied up running a long query or something
-A timer event, especially one that repaints a form like this, may slow down the process it is running alongside.
 
Last edited:
Hi Atomic Shrimp

Thanks for your help with this. :)

Your Example Works it scans left to right and then from right to the middle and stops there is there a way to make this scan continuously? left to right and right to left and so on ?

Thanks
Rob
 
There was a bug in the code earlier - edited and fixed now, but probably after you first saw the code - try what's up there now - it should work now.
 
There was a bug in the code earlier - edited and fixed now, but probably after you first saw the code - try what's up there now - it should work now.


Hi Atomic Shrimp.

Thanks A lot mate :D
Works Like a charm now.

I am going to use this on my start up form as it loads with colored squares as a progress meeter
Thanks for the help (Have Clicked your scales for your rep)

Regards
rob :)
 
My pleasure.

I just noticed a couple of lines of redundant code in there - the lines in red do nothing useful and can be pruned out:
(when the highlight is on the label at one end, it can't have been at the other end immediately before)
Code:
Private Sub Form_Timer()
Dim strTemp As String

strTemp = Trim(Me.Label0.Tag)
If (strTemp = "" Or strTemp = "5") Then strTemp = "1"
Select Case strTemp
Case Is = "1"
Me.Label0.ForeColor = vbRed
Me.Label1.ForeColor = vbBlack
[COLOR="Red"]Me.Label2.ForeColor = vbBlack[/COLOR]
Case Is = "2", "4"
Me.Label0.ForeColor = vbBlack
Me.Label1.ForeColor = vbRed
Me.Label2.ForeColor = vbBlack
Case Is = "3"
[COLOR="red"]Me.Label0.ForeColor = vbBlack[/COLOR]
Me.Label1.ForeColor = vbBlack
Me.Label2.ForeColor = vbRed
End Select
Me.Repaint
Me.Label0.Tag = Str(Val(strTemp) + 1)
 
End Sub
(In truth, there's probably an altogether more efficient way of doing it altogether).
 
actually, sounds like a nice idea, without seeing it in action.

i found a chumk of code that displays a big image (any image - jpeg or bitmap) fades it in, then gradually fades it out. that looks nice also
 
I think It looks Good , Just different to the normal progress meeter :)

Just one thing more (sorry should have asked originally)

Is there a way to also close the form with the meeter on in the timer function.

IE:- the meeter will go through say 6 scans then the form closes

any help is very much appreciated

Thanks
Rob :)
 
1. To close a form after X cycles, make the timer code decrement a variable that is in the form's class module declaration area. Such variables are available for as long as that form is open. Set it to some number on form_open (or form_load) and then count it down in the timer. When the counter hits zero, do a DoCmd.Close of the form.

2. A type of home-grown progress bar that I use sometimes is to build two overlapping rectangles. To start the bar, be sure that both rectangles have the same TOP and LEFT values. Make the "bottom" bar have a background color and a border color. Make the top bar (bottom/top as in: move to top, move to bottom) have a different color, no border, same HEIGHT as the bottom bar, and WIDTH = 1. Then in the timer, increment the width until it reaches the width of the bottom bar. This gives me much finer grain over the Access standard progress bar that I almost never use the standard one.

It is also possible to interpolate in the case where you know how many times you will do something. Let's say you know you have M records to process and you can count the number of records processed so far (in N). Then the width of the top bar is just

topbar.width = N * bottombar.width / M

where N and M are of type LONG. The bigger the width of the bottom bar, the finer the grain of the progress bar, since it is usually in units of twips (=24/inch).


If you REALLY want to get sexy, limit the width of the top bar and when it reaches that width, start moving the LEFT property of the bar. Then a little bar slides across the bottom bar. When you reach the point where LEFT+WIDTH of the top bar equals WIDTH of the bottom bar, you could choose to increment LEFT and decrement WIDTH of the top bar until it reaches width 0, in which case you could reset everything and start over again in the cycle. Simple to program, sexy as hell to the uninitiated, and doesn't involve use of "foreign" or ActiveX progress indicators from the extended toolbars.
 
Hi The_Doc_Man.

Thanks for the reply :)

Could you explain more about the solution to close the form?

Maybe a sample code please and more info on were to place it

thanks to all that help me ,This forum is the best ! :D

Regards
Rob :)
 
Hi all

OK sorted the form Close

What I Done was open another form From the splash onload event as hidden and used the timer event of that form to close the splash form then itself

Thanks for all the help with this :D

Regards
Rob :)
 

Users who are viewing this thread

Back
Top Bottom