Solved

Newb Q about command1_click while a another Sub Procedure is currently running

Posted on 2006-11-05
4
159 Views
Last Modified: 2010-04-30
I have a procedure (Sub Collecting) running that involves waiting for a webpage to load and collects data. I have command button that when clicked (Sub Command1_Click) basically says to skip the slow loading page and to continue on with some variable settings. If Sub Collecting is running and waiting for the page to load, and I go ahead and click on Command1, does Sub Collecting come to an end? Or does VB save its spot in Sub Collecting and then return to where it left off after Sub Command1_click is done running? Sub Command1_Click does not call on any other procedures.

So ultimately, what happens when Sub Collecting is in the middle of running and I click on Command1?
0
Comment
Question by:JohnDoeSr
  • 2
  • 2
4 Comments
 
LVL 15

Expert Comment

by:JackOfPH
Comment Utility
You can use "DoEvents" so that you can do something while your procedure runs...
0
 
LVL 10

Accepted Solution

by:
cool12399 earned 250 total points
Comment Utility
If you don't do anything else -- (assuming you are using the webBrowser control) -- sub collecting will continue to wait, and will actually execute as soon as the webppage is finished loading. So basically your command button and the sub collecting will both be running (basically) at the same time.

So:

1. No, sub collecting does not come to an end. It continues to wait for the webpage until it either decides it *couldn't* load it, or it actually *does* load it.
2. Sub collecting & your command both run at the same time. (It is called 'asyncronous' execution. So it is possible that if you have a really long procedure in your command button, that that would be run at exactly the same time as the webbrowser page was loaded).

Anticipating your next question (which should be in a new question :)) -- but I'll answer it anyways -- if you *are* using the webbrowser control, you can find out when the page "is" loaded by using the "documentComplete" function.
0
 
LVL 15

Expert Comment

by:JackOfPH
Comment Utility
>>So ultimately, what happens when Sub Collecting is in the middle of running and I click on Command1?

The program will hang up until the procedure completes all its task... you cannot click the command button.

Thats why you should use DoEvents on top of the procedure to allow multi tasking...
0
 
LVL 10

Expert Comment

by:cool12399
Comment Utility
lol, jack -- actually you are mistaken... the webbrowser control runs separately (it is not like clicking on two command buttons). try it out for yourself.

cheers!
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

762 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

7 Experts available now in Live!

Get 1:1 Help Now