Midi form


Hi Experts,

I want a login form to my midi form, how do i get the midi form to open when the correct password is entered using an if statement.

user name = txtuname
password = txtpword

 if txtpword.text = "letmein" then.......

foster30Asked:
Who is Participating?
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Start your Project with Sub Main().  Click on Project --> Properties and change the "Startup object:" dropdown to "Sub Main".  (If you are using VB.Net 2005 then you have to UNCHECK the "Enable application framework" checkbox to be able to select "Sub Main".)

Declare a Global Public variable to hold whether Login was successful or not.
Now show your Login form using ShowDialog.
After it closes, run your main form if applicable:

    Module Module1

        Public Login As Boolean = False ' <---- Set this to True from frmLogin if appropriate

        Public Sub Main()
            Dim fL As New frmLogin
            fL.ShowDialog() ' <---- code holds here until fL is closed
            If Login Then
                Application.Run(New frmMain)
            End If
        End Sub

    End Module

From inside frmLogin...

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If TextBox1.Text = "James Bond" AndAlso TextBox2.Text = "007" Then
            Login = True ' this sets the global variable in our Module
        End If
        Me.Close()
    End Sub
0
 
sk33v3Commented:
if me.password.text="password" and me.username.text="username" then
     dim MainForm as MyMDIForm
     MainForm.show
end if

Where Me.Password is a textbox on the form for your password and Me.Username is a textbox for your username on the form. Also replace MyMDIForm with the name of your MDI Form.
0
 
foster30Author Commented:
thanks a lot guys, that really helped.
0
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.