Form not showing until File Functions complete

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ConieFL
    New Member
    • Sep 2007
    • 8

    #1

    Form not showing until File Functions complete

    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!
  • VBPhilly
    New Member
    • Aug 2007
    • 95

    #2
    Originally posted by ConieFL
    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 SearchingForFil e
    Doevents
    ... whatever your code is here
    loop
    End Sub

    Comment

    • VBPhilly
      New Member
      • Aug 2007
      • 95

      #3
      Originally posted by ConieFL
      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.

      Comment

      • ConieFL
        New Member
        • Sep 2007
        • 8

        #4
        Thanks I will give them both a try.

        Comment

        Working...