Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2006-11-05
4
Medium Priority
?
166 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 15

Expert Comment

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

Accepted Solution

by:
cool12399 earned 1000 total points
ID: 17878349
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
ID: 17878367
>>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
ID: 17986032
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

618 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