Midi form

Posted on 2006-05-10
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
    LVL 9

    Expert Comment

    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 85

    Accepted Solution

    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

    thanks a lot guys, that really helped.

    Featured Post

    Live: Real-Time Solutions, Start Here

    Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

    Join & Write a Comment

    Suggested Solutions

    A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
    Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    754 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

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now