Setelah kita melihat contoh kegiatan aplikasi penerimaan siswa gres pada sekolah mengemudi abie stir karawang menggunakan visual basic. aku akan memperlihatkan instruksi listingnya (sourcecode).
Berikut ini ialah source code/ instruksi listing form user.
Pertama Silahkan Buat form dibawah ini, dan ubah name pada propertiesnya :
Catatan :
A. buat 2 textbox gres dan beri name "tkodeuser2" dan "tlevel" pada propertiesnya Visible=false
B. Pada components tambahkan :
- crystal report control,
- microsoft hierarchical flexgrid control 6.0,
- microsoft windows common control 6.0,
- microsoft windows common control-2 6.0
D. Tambahkan Timer
E. Simpan Form dengan nama "floginuser"
1. Klik pada cblogin dan pastekan kodingnya :
Call koneksi
rsdatauser.Open "select*from tuser where kodeuser='" & tkodeuser2.Text & "' and password='" & tpassword.Text & "'", KON
If rsdatauser.EOF Then
MsgBox "Password anda salah", vbCritical
tpassword.Text = ""
tpassword.SetFocus
Else
rsdatalogin.Open "insert into riwayatlogin values('" & tkodeuser2 & "','" & tjam & "','" & tltgl & "')", KON
tlevel = rsdatauser!Level
If tlevel = "Admin" Then
fmenu.Show
Unload Me
a = rsdatauser!namauser
MsgBox "Anda Login sebagai Admin", vbInformation, "INFO"
MsgBox "Selamat Datang " & a & "", vbInformation, "ADMIN"
fmenu.StatusBar.Panels(2) = rsdatauser!kodeuser
fmenu.StatusBar.Panels(4) = rsdatauser!namauser
fmenu.StatusBar.Panels(6) = rsdatauser!Level
fmenu.mganti.Enabled = True
fmenu.mdata.Enabled = True
fmenu.mdatauser.Enabled = True
fmenu.mdatabiaya.Enabled = True
fmenu.mdatasiswa.Enabled = False
fmenu.mriwayat.Enabled = True
fmenu.mlogout.Enabled = True
fmenu.mloguser.Enabled = False
fmenu.mmobil.Enabled = True
fmenu.mjam.Enabled = True
'user-----------------------------------------------------------------------------------
Else
fmenu.Show
Unload Me
b = rsdatauser!namauser
MsgBox "Anda Login sebagai User", vbInformation, "INFO"
MsgBox "Selamat Datang " & b & "", vbInformation, "USER"
fmenu.StatusBar.Panels(2) = rsdatauser!kodeuser
fmenu.StatusBar.Panels(4) = rsdatauser!namauser
fmenu.StatusBar.Panels(6) = rsdatauser!Level
fmenu.mganti.Enabled = True
fmenu.mdata.Enabled = True
fmenu.mdatabiaya.Enabled = False
fmenu.mdatauser.Enabled = False
fmenu.mdatasiswa.Enabled = True
fmenu.mjadwal.Enabled = True
fmenu.mtransaksi.Enabled = True
fmenu.mlaporan.Enabled = True
fmenu.mlogout.Enabled = True
fmenu.mloguser.Enabled = False
fmenu.mmobil.Enabled = False
fmenu.mjam.Enabled = False
End If
End If
rsdatauser.Open "select*from tuser where kodeuser='" & tkodeuser2.Text & "' and password='" & tpassword.Text & "'", KON
If rsdatauser.EOF Then
MsgBox "Password anda salah", vbCritical
tpassword.Text = ""
tpassword.SetFocus
Else
rsdatalogin.Open "insert into riwayatlogin values('" & tkodeuser2 & "','" & tjam & "','" & tltgl & "')", KON
tlevel = rsdatauser!Level
If tlevel = "Admin" Then
fmenu.Show
Unload Me
a = rsdatauser!namauser
MsgBox "Anda Login sebagai Admin", vbInformation, "INFO"
MsgBox "Selamat Datang " & a & "", vbInformation, "ADMIN"
fmenu.StatusBar.Panels(2) = rsdatauser!kodeuser
fmenu.StatusBar.Panels(4) = rsdatauser!namauser
fmenu.StatusBar.Panels(6) = rsdatauser!Level
fmenu.mganti.Enabled = True
fmenu.mdata.Enabled = True
fmenu.mdatauser.Enabled = True
fmenu.mdatabiaya.Enabled = True
fmenu.mdatasiswa.Enabled = False
fmenu.mriwayat.Enabled = True
fmenu.mlogout.Enabled = True
fmenu.mloguser.Enabled = False
fmenu.mmobil.Enabled = True
fmenu.mjam.Enabled = True
'user-----------------------------------------------------------------------------------
Else
fmenu.Show
Unload Me
b = rsdatauser!namauser
MsgBox "Anda Login sebagai User", vbInformation, "INFO"
MsgBox "Selamat Datang " & b & "", vbInformation, "USER"
fmenu.StatusBar.Panels(2) = rsdatauser!kodeuser
fmenu.StatusBar.Panels(4) = rsdatauser!namauser
fmenu.StatusBar.Panels(6) = rsdatauser!Level
fmenu.mganti.Enabled = True
fmenu.mdata.Enabled = True
fmenu.mdatabiaya.Enabled = False
fmenu.mdatauser.Enabled = False
fmenu.mdatasiswa.Enabled = True
fmenu.mjadwal.Enabled = True
fmenu.mtransaksi.Enabled = True
fmenu.mlaporan.Enabled = True
fmenu.mlogout.Enabled = True
fmenu.mloguser.Enabled = False
fmenu.mmobil.Enabled = False
fmenu.mjam.Enabled = False
End If
End If
2. Klik pada cbersih dan pastekan kodingnya :
tkodeuser.Enabled = True
tkodeuser.Text = ""
tpassword.Enabled = False
tpassword.Text = ""
tkodeuser.SetFocus
tkodeuser.Text = ""
tpassword.Enabled = False
tpassword.Text = ""
tkodeuser.SetFocus
3. Klik pada timer yg tlah dibentuk dan pastekan kodingnya :
tjam.Text = Time
tltgl.Text = Format(Date, "yyyy-m-d")
tltgl.Text = Format(Date, "yyyy-m-d")
4. Klik pada tkodeuser dan pastekan kodingnya (deklarasinya Keypress):
If KeyAscii = 13 Then
Call koneksi
rsdatauser.Open "select*from tuser where kodeuser='" & tkodeuser.Text & "' or username='" & tkodeuser.Text & "'", KON
If rsdatauser.EOF Then
MsgBox "Kodeuser/username tidak ditemukan, silahkan masukan Kodeuser/username lainnya !", vbCritical
tkodeuser.Text = Clear
Else
tpassword.Enabled = True
tpassword.SetFocus
tlevel.Text = rsdatauser.Fields("level")
tkodeuser2.Text = rsdatauser.Fields("kodeuser")
cblogin.Enabled = True
tkodeuser.Enabled = False
End If
End If
Call koneksi
rsdatauser.Open "select*from tuser where kodeuser='" & tkodeuser.Text & "' or username='" & tkodeuser.Text & "'", KON
If rsdatauser.EOF Then
MsgBox "Kodeuser/username tidak ditemukan, silahkan masukan Kodeuser/username lainnya !", vbCritical
tkodeuser.Text = Clear
Else
tpassword.Enabled = True
tpassword.SetFocus
tlevel.Text = rsdatauser.Fields("level")
tkodeuser2.Text = rsdatauser.Fields("kodeuser")
cblogin.Enabled = True
tkodeuser.Enabled = False
End If
End If
5. Buat form_activate dan pastekan kodingnya :
tkodeuser.Enabled = True
tpassword.Enabled = False
tkodeuser.SetFocus
tkodeuser.MaxLength = 10
tpassword.PasswordChar = "*"
tpassword.MaxLength = 5
tlevel.Visible = False
cblogin.Enabled = False
Me.Width = 11325
Me.Height = 4635
tpassword.Enabled = False
tkodeuser.SetFocus
tkodeuser.MaxLength = 10
tpassword.PasswordChar = "*"
tpassword.MaxLength = 5
tlevel.Visible = False
cblogin.Enabled = False
Me.Width = 11325
Me.Height = 4635
6. ketik koding dibawah ini paling atas (sbg pengenal variabel) :
Dim a, b As String
Sumber http://www.hendrisetiawan.com