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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

making a pop-up progress bar on loading status? 3

Status
Not open for further replies.

Nate1749

Programmer
Nov 1, 2002
204
US
I've got a form that takes ~2-5 seconds to load (contains a dozen list boxes which are all queries that are doing group by's from a non-normalized linked .csv file) & I can make a pop-up that says "loading," but I was hoping I could have some type of animation in the pop-up resembling a status loading bar.

The bar doesn't have to actually show them the progress (ie when bar gets to the end it actually loads... although at that would be nice) it can just be a slow animation that moves and then when it gets to the end starts over again... I was wondering if anyone else has done something similiar or has a better idea on how to accomplish this.

-Nate
 
Ive just managed to work this out myself.
stick this code in the timer event of your form (set the timer to 5)
--------------------
Private Sub Form_timer()
Box2.width = 0

Do While Box5.width < 3922
Box2.width = Box2.width + Int(2 * Rnd())
Me.Repaint

Loop
End
End Sub
-------------------------
(you can put it on the load event but for some reason the timer event makes it look a lot smoother)
now create two boxes on the form. box 1-width 7 cm effect sunken and box 2-width 0 effect raised.
box 1 should be transparent and box 2 any color you like. you'll then need to place box 2 inside box 1 which should be slightly taller than box 2 about 0.3 cm. now run the form
 
or, if you don't want to set a fixed amount of time to completion you can set something like this to a timer event (make sure the time interval is short, in the 50-100 millisecond range, tweaked to look as smooth as possible - just remember that the faster you run the timer the slower the form will load, so compromising some speed here should be acceptable):

Option Compare Database
Option Explicit

Const pi As Double = 3.14159
Dim x As Double

Private Sub Form_BeforeScreenTip(ByVal ScreenTipText As Object, ByVal SourceObject As Object)

End Sub

Private Sub Form_Timer()

With Me.line

.Height = 2880 * (Sin((x * pi / 90)) ^ 3) ^ 2
.Width = 2880 * (Cos(x * pi / 90)) ^ 2
.Left = 2880 + 1440 * Sin(x * pi / 60)
.Top = 2880 + 576 * Cos(((x + (Sin(x) / 20)) * pi / 60))

End With

With Me.Line1


.Height = 2380 * (Cos((x * pi / 90)) ^ 3) ^ 2
.Width = 3600 * (Cos(x * pi / 90)) ^ 2
.Left = 3200 + 1440 * Cos(x * pi / 60)
.Top = 3200 + 576 * Sin(((x + (Sin(x) / 20)) * pi / 60))

End With

With Me.Line2

.Height = 1500 * Abs(Cos((x * pi / 90)) ^ 3)
.Width = 4000 * (Sin(x * pi / 90)) ^ 4
.Left = 3000 + 2000 * Cos(x * pi / 60)
.Top = 3000 + 700 * Sin(((x + (Sin(x) / 20)) * pi / 60))

End With

x = x + 1 + Rnd(x)

End Sub

just make sure your form is big enough and enjoy the dancing lines (you might want to add/remove lines or tweak their motion, but here's some inspiration at least)
 
Spiralmind,
been playing with all morning and am fascinated. how would i get it to completely spin the line around. the lines seem to move on two axis.
 
Hey spiralmind,

just checked this out, don't think it will help me with anything I've done but who cares it's awesome, have a star!!!

Cheers

Sam

&quot;You couldn't fool your mother on the foolingest day of your life if you had an electrified fooling machine.&quot; - Homer
 
to make the lines spin all the way around you would have to write a conditional statement to detect when the sine and cosine functions dip into negative output values and change the slant direction of each of the lines. this is because access, unlike a more purely mathematical graphing system, can't display an object with a negative width or height.

the problem with adding the conditional part of the statement would be that the &quot;dancing lines&quot; would consume a lot more processing power and be less effective as a distraction for your user while you try to load something in the background, as that loading process would then be almost twice as long. as a screen-saver type of thing, though, it might be worth it.
 
on a somewhat related note:

to make a progress meter for something that involve a large number of repetitive iterations of code within the same loop (such as appending a large number of records to a table, moving a large batch of files...) you can create a subroutine like this:

Sub subProgressUpdate(intCurrent as Integer, intTotal as Integer)

me.boxProgress.Width = 2880 * (intCurrent/intTotal)

End Sub

place that sub in the module of your progress form, create a progress box that starts out with a width of zero, and a background box with a different color that has a width of 2880 twips (2 inches). Call the above routine from your repetitive loop in a manner similar to thi sexample:


For i = 0 to UBound(SomeArray)

' some code here dealing with each entry in array

Call subProgressUpdate(i,UBound(SomeArray))

Next i

This example isn't terrible optimized (you could, for instance replace the Ubound function with a variable calculated once instead of within every interation of the loop), but it shows a way to create a progress meter for a long, repetitive task that actually tracks the progress of that task rather closely and smoothly. I've used this one myself for moving hundreds of files around a network because it's much more accurate than using a timer-based solution and has a fairly low overhead.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top