How to load a MDI form from a Login form

I need to how do I show a MDI form from the Login screen.

I have tried with this code. But its not working.

                Dim MDIMain As New Form
                MDIMain.MdiParent = Me

and I have tried this one also.
                Dim MDIMain As New Form
                ''MDIMain.MdiParent = Me

Its not working. Please help me
Who is Participating?
Mike TomlinsonMiddle School Assistant TeacherCommented:
Click on Project --> Properties and click on the "View Application Events" button in the bottom right.

Now, across the top of the code editor are two dropdowns.
Change the left dropdown from "(General)", to "(MyApplication Events)".
Next change the right dropdown from "(Declarations)", to "Startup".

Add some code to the autogenerated event so it looks something like this:

        Private Sub MyApplication_Startup(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) Handles Me.Startup
            Dim fl As New frmLogin
            If fl.ShowDialog <> DialogResult.OK Then
                e.Cancel = True ' cause app to close
            End If
            ' otherwise, app continues loading whatever Form the "Startup Object" is set too...
        End Sub

Finally, in "frmLogin", you need to set the DialogResult property of that form (at run-time via code of course!) to indicate whether login was sucessful or not.
Bob LearnedCommented:
You could set the startup object to Sub Main, and show the Login form modally, and get the DialogResult from the form before showing the main form.

Mike TomlinsonMiddle School Assistant TeacherCommented:
What version VB.Net?

If 2003 (or below) then do it Bob's way.

If 2005 then leave the MdiForm as the Startup Object and use the Application.Startup() event to show your login form as a Dialog.  If login fails than set the e.Cancel property to true to cancel the loading of the application.
ananmananAuthor Commented:
I'm using 2005. I'm not very clear how to do it. Can u please guide me to do it.
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.