Jumat, 20 Januari 2012
Listing Progaram Login
' password version 1.0
' created by: Mr. Jake Rodriguez Pomperada, MAED-IT
' date : March 30, 2009 Monday
' tool : Visual Basic 6.0
' email : jakerpomperada@yahoo.com
' location : purok pag-asa, barangay alijis 6100 bacolod city, negros
' occidental philippines
Option Explicit
Dim WrongLogin As Integer
Dim rs As ADODB.Recordset
Private Sub Command1_Click()
On Error GoTo errhandler
If WrongLogin = 2 Then
Call MsgBox("kamu sudah 3 kali gagal. silahkan keluar!!!", vbOKOnly, "Sorry")
End
End If
WrongLogin = WrongLogin + 1
Form1.txt_try.Text = Str(WrongLogin)
If UCase(txtUserName.Text) = "" Or IsNull(txtUserName.Text) = True Then
Call MsgBox("Nama Harus di isi.", vbOKOnly, "Nama")
txtUserName.SetFocus
Exit Sub
End If
If UCase(txtPassword.Text) = "" Or IsNull(txtPassword.Text) = True Then
Call MsgBox("Password Harus di isi.", vbOKOnly, "Password")
txtPassword.SetFocus
Exit Sub
End If
Open_cn
Set rs = New ADODB.Recordset
rs.Open ("Select * from Login Where UserName= '" & UCase(txtUserName.Text) & "'"), cn, adOpenStatic, adLockOptimistic, _
adCmdText
If UCase(txtPassword.Text) <> rs.Fields("password") Then
Call MsgBox("Incorrect Password", vbOKOnly, "Login Error")
txtPassword.Text = ""
txtPassword.SetFocus
Exit Sub
Else
'Correct!
UserName = UCase(txtUserName.Text) 'May need in the future project
MsgBox ("Correct Login. This is where you open another form and close this one.")
'This is where you open a new form and close frmLogin
'Example:
'frmMain.show
'unload me
End If
Close_cn
Exit Sub
errhandler:
Call MsgBox("Incorrect Username", vbOKOnly, "Login Error")
txtUserName.Text = ""
txtPassword.Text = ""
txtUserName.SetFocus
Exit Sub
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Form1.Show
Form1.txtUserName.SetFocus
WrongLogin = 0
End Sub
Private Sub Txtusername_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Form1.txtPassword.SetFocus
End If
End Sub
Private Sub Txtpassword_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Form1.Command1.SetFocus
End If
End Sub
Option Explicit
Public UserName As String
Public DatabasePath As String
Public cn As ADODB.Connection
Module Login
Public Sub Open_cn()
Set cn = New ADODB.Connection
cn.CursorLocation = adUseClient
cn.Provider = "Microsoft.Jet.OLEDB.4.0"
cn.Properties("Data Source") = App.Path & "\login.mdb"
cn.Open
End Sub
Public Sub Close_cn()
cn.Close
Set cn = Nothing
End Sub
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar