Solved

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

Posted on 2006-11-05
4
164 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 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
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…

688 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