Create Login Form VB 6.0

In this steps, we call Step 5, before learn in this step, you must follow :
Step 1 : Cteate New Project
Step 2 : Create Main Form Application
Step 3 : Create Database and Tables
Step 4 : Create Connection Database Use Module

Open your latest Project :


Double Click Belajar VB
Below for your latest Proeject in Step 4 :

Click Project
Add Form
Click Open
Change name form be : LoginForm

and then please make below design in LoginForm


in Login form please fill below code :

Sub EnableMenu()
FormMainMenu.MenuLogin.Enabled = False
FormMainMenu.MenuLogout.Enabled = True
FormMainMenu.MenuMaster.Enabled = True
FormMainMenu.MenuTransaction.Enabled = True
FormMainMenu.MenuReport.Enabled = True
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Activate()
Text1 = ""
Text2 = ""
Text2.Enabled = False
End Sub
Sub Form_Load()
    Call OpenDB
    Text1.MaxLength = 20
    Text2.MaxLength = 20
    Text2.PasswordChar = "X"
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
    KeyAscii = Asc(UCase(Chr(KeyAscii)))
    If KeyAscii = 13 Then
        Call OpenDB
        Call SearchData
                If RSUsers.EOF Then
                    MsgBox "User not found, Please try again"
                    Text1 = ""
                Else
                Text1.Enabled = False
                Text2.Enabled = True
                Text2.SetFocus
                End If
    End If
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
    KeyAscii = Asc(UCase(Chr(KeyAscii)))
    If KeyAscii = 13 Then
        Command1.SetFocus
    End If
End Sub
Function SearchData()
    Call OpenDB
    RSUsers.Open "Select * From Users where User_Name='" & Text1 & "'", ConnectDB
End Function
Private Sub Command1_Click()
Dim User_Id As String
Dim NamaAdmin As String
Call OpenDB
        RSUsers.Open "Select * from Users where User_Name ='" & Text1 & "' and User_Password='" & Text2 & "'", ConnectDB
        If RSUsers.EOF Then
            MsgBox "Wrong Password, Please try again!"
            Text2 = ""
            Text2.SetFocus
        Else
            Unload Me
            FormMainMenu.Show
            Call EnableMenu
        End If
End Sub
Don't forget to fill below code in MainForm.

Sub DisableMenu()
MenuLogin.Enabled = True
MenuLogout = False
MenuMaster.Enabled = False
MenuTransaction.Enabled = False
MenuReport.Enabled = False
End Sub
Private Sub Form_Load()
Call DisableMenu
End Sub
Private Sub MenuExit_Click()
End
End Sub
Private Sub MenuLogin_Click()
LoginForm.Show vbModal
End Sub

In this Step, you can Download Just Click THIS LINK
Lets see next steps :)

Subscribe to receive free email updates:

0 Response to "Create Login Form VB 6.0"

Post a Comment