Solved

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

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
passing a value with stream reader AFTER a ";" 3 74
Advice in Xamarin 21 97
Export Data to Different .csv Files 26 114
transition to visual .net from vb6 5 39
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

837 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