Midi form

Posted on 2006-05-10
Medium Priority
Last Modified: 2010-04-23

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.......

Question by:foster30

Expert Comment

ID: 16649717
if me.password.text="password" and me.username.text="username" then
     dim MainForm as MyMDIForm
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.
LVL 86

Accepted Solution

Mike Tomlinson earned 150 total points
ID: 16650406
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
    End Sub

Author Comment

ID: 16660323
thanks a lot guys, that really helped.

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Integration Management Part 2
Screencast - Getting to Know the Pipeline

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question