Solved

processing while a progress bar is loading

Posted on 1999-01-29
3
168 Views
Last Modified: 2010-05-03
Let's say I have certain portion of codes which need to be run while I let the user see the progress bar on the form. How do I load the form containing the progress bar and at the same time it is processing something behind it?
0
Comment
Question by:ute
  • 3
3 Comments
 
LVL 10

Accepted Solution

by:
caraf_g earned 50 total points
ID: 1471149
Load the form first, then show it modeless

FormX.Show vbModeless

That displays the form on the screen with the progress bar.

Then, in your main routine, start doing the processing that will take some time, and update the progress bar on formX

FormX.ProgressBar. (etcetera)

Every time you update the value of the progress bar, follow it by
DoEvents
So that the user looking at the form will see the progress bar moving (without the DoEvents they won't see anything).

Good luck

0
 
LVL 10

Expert Comment

by:caraf_g
ID: 1471150
PS - if the form containing the progress bar is your main form, you'll have to resort to using a Sub Main

Create a new BAS module in your VB project

In your BAS module, declare a sub as follows

Private Sub Main()

'Within this sub, you must load the main form as stated in the answer.
Form1.Show vbModeless

'Now you do your processing and update the progress bar on the main form

'Finally, hide form1
Form1.Hide

'...and show it modally to "actually" start the application
Form1.Show vbModal


End Sub


In your Project Properties you must set your Startup Object to Sub Main
0
 
LVL 10

Expert Comment

by:caraf_g
ID: 1471151
PS - if the form containing the progress bar is your main form, you'll have to resort to using a Sub Main

Create a new BAS module in your VB project

In your BAS module, declare a sub as follows

Private Sub Main()

'Within this sub, you must load the main form as stated in the answer.
Form1.Show vbModeless

'Now you do your processing and update the progress bar on the main form

'Finally, hide form1
Form1.Hide

'...and show it modally to "actually" start the application
Form1.Show vbModal


End Sub


In your Project Properties you must set your Startup Object to Sub Main
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now