By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,972 Members | 1,115 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,972 IT Pros & Developers. It's quick & easy.

Form not showing until File Functions complete

P: 8
In my main sub routine I have code similar to this

Form.Show
Call File_Routine

The file routine searches for a configuration file, needed by the program.
If the configuration file is not found then the file routine continues to search for certain files so that there paths can be stored in a newly created configuration file. While the program searches for the files, I am trying to display progress messages to the user.


The problems I have are the Form does not completly load before the File Routine is invoked, it looks like a ghost form. Only after the file routine is complete does the form completely show. Because of this I cannot display the progress messages to the user.( I was using a hidden text box on the form to display the messages, making it visable when needed). I tried this both with a startup form and on the main form.
I've also tried displaying a msgbox (which i really don't like) so that the user has to press ok before the file routine starts. This allows my form to load, and display some text, but as soon as the user presses the OK button the text disappears and none of the other progress messages display.

Please Help!
Sep 20 '07 #1
Share this Question
Share on Google+
3 Replies


VBPhilly
P: 95
In my main sub routine I have code similar to this

Form.Show
Call File_Routine

The file routine searches for a configuration file, needed by the program.
If the configuration file is not found then the file routine continues to search for certain files so that there paths can be stored in a newly created configuration file. While the program searches for the files, I am trying to display progress messages to the user.


The problems I have are the Form does not completly load before the File Routine is invoked, it looks like a ghost form. Only after the file routine is complete does the form completely show. Because of this I cannot display the progress messages to the user.( I was using a hidden text box on the form to display the messages, making it visable when needed). I tried this both with a startup form and on the main form.
I've also tried displaying a msgbox (which i really don't like) so that the user has to press ok before the file routine starts. This allows my form to load, and display some text, but as soon as the user presses the OK button the text disappears and none of the other progress messages display.

Please Help!
Two choices:

You can REFRESH the form, before the routine:

Form1.Refresh.

And/Or, you can use a "DOEVENTS" keyword.

In the loop where you search for files, add "DoEvents"
This will yield to other processing (like fully loading your form).

You could also combine the above:

Form1.Refresh
Call FileRoutine

Public Sub FileRoutine()
Do While SearchingForFile
Doevents
... whatever your code is here
loop
End Sub
Sep 20 '07 #2

VBPhilly
P: 95
In my main sub routine I have code similar to this

Form.Show
Call File_Routine

The file routine searches for a configuration file, needed by the program.
If the configuration file is not found then the file routine continues to search for certain files so that there paths can be stored in a newly created configuration file. While the program searches for the files, I am trying to display progress messages to the user.


The problems I have are the Form does not completly load before the File Routine is invoked, it looks like a ghost form. Only after the file routine is complete does the form completely show. Because of this I cannot display the progress messages to the user.( I was using a hidden text box on the form to display the messages, making it visable when needed). I tried this both with a startup form and on the main form.
I've also tried displaying a msgbox (which i really don't like) so that the user has to press ok before the file routine starts. This allows my form to load, and display some text, but as soon as the user presses the OK button the text disappears and none of the other progress messages display.

Please Help!
one other advantage with DoEvents,

without it, you have a 'frozen form'. Users wont be able to move or click anything until your loop completes.

Using DoEvents, there is no 'freeze'. this is good if you dont want users to do anything. But, bad if Users have to wait. They will think the app is not responding.
Sep 20 '07 #3

P: 8
Thanks I will give them both a try.
Sep 20 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.