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

Passing information to Progress bar from module 1

Status
Not open for further replies.

JohnVogel

Programmer
Apr 19, 1999
117
US
I am designing part of a backup program for windows. There will be several different forms for front-ends and I need to write a self-standing module which I can call from different programs/forms.

I have a function that checks the windows version, finds different directors and files and then backs up those files. I would like for my module to return information to the calling form such as Status (Reading... writing... etc) and a progress bar of % complete.

I'm afraid I've been out of Programming for a while, and I'm having a lil problem jogging my brain. How can I pass these variables from my module to the form, while it's doing it's thing?

Thanks In Advance


John Vogel
john@thecompuwizard.com
 
Create a public method in the form that accepts a progress value. When you start your backup, you'll need to pass a copy of the form instance variable into it, so that it knows who to tell of it's progress.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
In the module, put something like:

Form1.Progress1.Value = X

Where X is the percent of the Max Value...

Have Fun, Be Young... Code BASIC
-Josh
cubee101.gif


PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
Hi mate,

What you actually should do is put your code in a class.

You should then declare an event in the class such as:

Event ProgressChanged(ProgressAmount as long , Maximum as long)

Then in your code when you want the progress to change you use Raisevent ProgressChanged(123,1000)

In your main form declare the class as

public withevents MyClass as MyBackupClass

You will then be able to access the On_ProgressChanged event of MyBackupClass

When this event runs you need to update your progress meter on your form.

Create a public function on the form called UpdateStatus(byval Value as long, byval MaxValue as long ) and call that whenever the event is raised.

When you raise the event you may want to only do it after every x amount of iterations in order to stop the progress bar being updated unneccessarily.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top