Status / Loading Bar

User avatar
Joseph
3StarLounger
Posts: 206
Joined: 31 Dec 2010, 22:23
Location: Columbia Falls, MT

Status / Loading Bar

Post by Joseph »

I have scoured the internet looking for some good status bar examples, the problem is, I've found too many.

I figure rather than wasting my time, I'd ask sir Hans if he knew of any good status bar code.

You may recall the payroll entry form where the user can select many employees at once to enter their employee work hours. Well, if all employees are selected, the process can take up to 20 sec. or so to complete. I'd like to add a status bar to this event if possible.

User avatar
HansV
Administrator
Posts: 78494
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Status / Loading Bar

Post by HansV »

It's quite simple, actually: before a lengthy operation, insert this line:

Application.StatusBar = "Processing worked hours. This may take some time."

and after it, clear the status bar using

Application.StatusBar = False

If you have a loop, you can provide detailed information:

Code: Select all

  n = ...
  For i = 1 To n
    Application.StatusBar = "Processing worked hours for employee " & i & " of " & n
    ...
    ...
  Next i
  Application.StatusBar = False
This will display e.g.

Processing worked hours for employee 5 of 37
Best wishes,
Hans

User avatar
Joseph
3StarLounger
Posts: 206
Joined: 31 Dec 2010, 22:23
Location: Columbia Falls, MT

Re: Status / Loading Bar

Post by Joseph »

Thanks Hans...maybe it's a bit early here, but what would the "N" represent?

I got it, thanks.

User avatar
HansV
Administrator
Posts: 78494
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Status / Loading Bar

Post by HansV »

n would be the total number of items to process (e.g. the number of selected items in a list box, or ...)
Best wishes,
Hans