Solved

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

Posted on 2006-11-05
4
160 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
ID: 17878137
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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

896 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