swf

Sabtu, 15 Desember 2012

form login sederhana

setelah kemaren membuat postingan membuat form login sederhana , kali ini saya akan membuat form login dengan database ms excel 2003 di sertai module

sebelum nya buka
project> references >microsoft activex data object 2.7 library di centang
buka module , dan masukan code berikut:

Public ConnDB As New ADODB.Connection


Public Sub Main()
OpenDB
Form1.Show
End Sub


Public Sub OpenDB()
Dim koneksi As String
koneksi = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
koneksi = koneksi & App.Path & "\login.mdb;"
koneksi = koneksi & "Persist Security Info=False"

ConnDB.Open koneksi
End Sub


login.mdb ganti dengan nama database agan

selanjut nya masukan code berikut di tombol ok form login


Private Sub Command1_Click()
Dim ruser As New Recordset
Dim slist As String

slist = "select * from login where user = '" & Text1 & "'"
Set ruser = ConnDB.Execute(slist)
If ruser.EOF Or ruser.BOF Then
x = x + 1
MsgBox "user name salah,,silahkan masukan user yang lain..!!!!", vbCritical, "Message"
    Text1.Text = ""
    Text2.SetFocus
    Text2.Text = ""
    GoTo keluar
    End If
 
If ruser![password] = Text2 Then
ruser.Close
MDIForm1.Show      'atau form2.show

ConnDB.Close
Unload Me
Exit Sub
Else
 MsgBox "Password Anda Salah Silahkan Coba Lagi...!", vbCritical, "pesan"
    x = x + 1
    Text2.Text = ""
    Text2.SetFocus
    End If

keluar:
 If x = 3 Then
 End
End If
Text1.SetFocus

End Sub

Private Sub Form_Load()
x = o

End Sub



Private Sub Form_Unload(Cancel As Integer)
ConnDB.Open
End Sub

'from login where user itu dari database
'text1 = text user
'text2 = text password
Catatan : starup object nya di mulai dari submain bukan form 1 okey .
semoga bermanfaat ,
jika ingin file vb nya koment aja di bawah .
nanti ane kirim ke email agan

Tidak ada komentar:

:)) ;)) ;;) :D ;) :p :(( :) :( :X =(( :-o :-/ :-* :| 8-} :)] ~x( :-t b-( :-L x( =))

Posting Komentar