Tutorial Visual Basic – Make Advance Form Login

Berikut source code nya semoga bermanfaat bagi kalian yang membaca

CODE

Module

Option Explicit

Public conn As ADODB.Connection

Public Sub connect()
Set conn = New ADODB.Connection
conn.Open “Provider=Microsoft.Jet.OLEDB.4.0;Data Source=” & App.Path & “\myDatabase.mdb;Persist Security Info=False”
End Sub

Sub main()
connect
frmLogin.Show
End Sub

formLogin
 

Private Sub cmdCancel_Click()
End
End Sub

Private Sub cmdOK_Click()

Dim rs As New ADODB.Recordset

rs.Open “SELECT * FROM tblUser WHERE username = ‘” & txtUserName & “‘”, conn, adOpenStatic, adLockReadOnly
If rs.RecordCount <> 0 Then
If txtPassword = rs!password Then

MsgBox “Username and Password Succesful!”
‘Remove msgbox above then call a form to be load if login is succesful!

Else
MsgBox “Invalid Password, try again!”, , “Login”
End If
Else
MsgBox “Invalid Login, try again!”, , “Login”

End If
rs.Close
Set rs = Nothing

End Sub

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s