Need to make startup form visible once .exe program is ran!

How may I adjust the coding below to allow me to see the form once a person opens up the executable?   Most of the time they will pass a parameter of an Access database and it will run the Test_DB() on the particular database to adjust it along with a Progress Bar to show action.  The problem is that I have it under the Form_Load event and thus doesn't show the form.

I understand what I"m doing wrong but I don't understand how to fix or adjust the syntax to give me what I want.

Please help and thank you.

Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    Dim sMsg As String
    Dim sPath As String
    Dim returnValue As String()

    sMsg = "...complete startup of program...check for parameter and if it exists then runs the code on the database..."
    returnValue = Environment.GetCommandLineArgs()
    If returnValue.Length > 1 Then
      sPath = returnValue(1).ToString()
      Catch exError As Exception
        ErrorMessageString = exError.ToString & " - " & exError.Message
        Call ExceptionClassObject.WriteExceptionErrorToFile(ExceptionErrorFileString, Me.Name, sMsg, ErrorMessageString, WriteErrorMessageString)

      End Try
    End If

  End Sub

Open in new window

Who is Participating?
Mike TomlinsonMiddle School Assistant TeacherCommented:
What version VB.Net are you using?

To make it start after the form has shown itself use the Shown() event instead of the Load() event.

If you have an early version of .Net then you can force the form to display using this at the top of the Load() event:


It really sounds like the work should be placed into a separate thread but the best approach depends on your version of VB.Net.
Mike TomlinsonMiddle School Assistant TeacherCommented:
Could you explain a little more what is supposed to happen (and what is happening that shouldn't)....
stephenlecomptejrAuthor Commented:
Several steps happen

1. Within Access 2007, a command is given to open my .exe program and pass the name of the database with:  StartDoc ""I:\EC\0MSAccess\UpdateMSAccess.exe""  "C:\Test\adjustme.accdb""

2.  It closes out of C:\Test\adjustme.accdb

3. When the .exe file opens it takes the database and starts making adjustments very quickly.  

As the adjustments are made, I have coding that displays a Progress Bar as it loops through the database making adjustments to queries, forms and reports.  

But the frmMain.vb (which is the only form in the program) is not visible because its at the Form_Load event.

4.  Once the adjustments are completed it finally opens C:\Test\adjustme.accdb with its adjustments.

5.  Closes out of the .exe program.

I would rather want the form to display itself and show the progress bar as to what it is doing.  

Because people double-click on the Access file again - realizing the database is being updated with the latest queries, forms and reports.
stephenlecomptejrAuthor Commented:
Because people double-click on the Access file again - NOT realizing the database is being updated with the latest queries, forms and reports.
Move your code to the frmMain_Shown event. It will run after the form has been loaded.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.