gaby90boy Posted June 8, 2007 Report Posted June 8, 2007 Hello, and welcome to my simple login form tutorial. This is situated on the fact that you are using Visual Basic 6.01. Starting off you are going to need to open up Visual Basic 6.0 Development window, and create a standard .exe file2. Now you need to drag onto the form the correct command property.These are as follows:2 Command Buttons2 Text Boxes2 LabelsSet the following properties for the different controls.Command Button 1Name: cmdLoginCaption: LoginCommand Button 2Name: cmdCloseCaption: Close ProgramText Box 1Name: txtUsernameText: Leave this emptyText Box 2Name: txtPasswordText: Leave this emptyPasswordChar: * (Reccommended so that the text appears as stars, added security.)Label 1Caption: Username:Label 2Caption: PasswordNow that you have the correct controls on the screen then we can get down to the coding!In order to access the code of the program, right click anywhere on the form and click on view code.Code:'Global VariablesDim Username As String 'Username VariableDim Password As String 'Password VariablePrivate Sub cmdLogin_Click()Username = "TestUser1" 'What the Username Variable isPassword = "TestUser1" 'What the Password Variable is'If Statement Starting Here'It States that if the username is = to text box and password is = password text box, then it should login, else display error message!If Username = txtUsername And Password = txtPassword ThenfrmLoginSuccess.Show 'Shows the Login Success FormfrmLoginScreen.Hide 'Hides the Login ScreenElse'A Message box that displays you have entered the wrong username and passwordMsgBox ("You have entered the wrong username and password")End IfEnd SubPrivate Sub cmdClose_Click()Unload Me 'Closes the programEnd SubThis is a basic piece of code that checks that what is etnered in the username box, and what is entered in the password box, is equal to what the username and password variables have been set at.3. Now you need to name the forms. Click the form and go to the name property, and call the form frmLoginScreen.4. Now create a new form. The way to do this is to right click in the project explorer area, and click on new, then select form. Now call this form frmLoginSuccess.5. Now run the program and see if it works. In theory, when you have entered the correct username and password, it should hide the Login Form and show the Login Success form Quote