Setelah kita melihat contoh Program Visual Basic (VB) Penerimaan karyawan baru (Employee Recruitment). Maka Selanjutnya kita Membuat Penginputan Data tanggal tes tulis pada program penerimaan karyawan di Ms Visual Basic 6.0 dengan database Mysql phpmyadmin.
Selanjutnya ubah variabel name nya seperti dibawah ini :
- Buatlah Sub Aktif :
Sub aktif()
nokode.Enabled = True
tgl1.Enabled = True
tgl2.Enabled = True
tcari.Enabled = True
End Sub
nokode.Enabled = True
tgl1.Enabled = True
tgl2.Enabled = True
tcari.Enabled = True
End Sub
- Buat Sub Nonaktif :
Sub nonaktif()
nokode.Enabled = False
tgl1.Enabled = False
tgl2.Enabled = False
tcari.Enabled = False
cmdsave.Enabled = False
cmdcancel.Enabled = False
cmdedit.Enabled = False
cmdupdate.Enabled = False
cmddelete.Enabled = False
End Sub
nokode.Enabled = False
tgl1.Enabled = False
tgl2.Enabled = False
tcari.Enabled = False
cmdsave.Enabled = False
cmdcancel.Enabled = False
cmdedit.Enabled = False
cmdupdate.Enabled = False
cmddelete.Enabled = False
End Sub
-Buat Sub tampil :
Sub tampil()
Call koneksi
rstanggaltest.Open "select*from tanggaltest", KON
Set grid.DataSource = rstanggaltest
End Sub
Call koneksi
rstanggaltest.Open "select*from tanggaltest", KON
Set grid.DataSource = rstanggaltest
End Sub
-Buat form_load :
Private Sub Form_Load()
Call nonaktif
cmdadd.Enabled = True
End Sub
Call nonaktif
cmdadd.Enabled = True
End Sub
- Buat Sub Bersih :
Sub bersih()
tgl1.Text = ""
tgl2.Text = ""
tcari.Text = ""
nokode.Text = ""
End Sub
tgl1.Text = ""
tgl2.Text = ""
tcari.Text = ""
nokode.Text = ""
End Sub
Silahkan pastekan ke "commandbutton" yang sesuai dengan name di bawah ini :
-cmdadd :
Private Sub cmdadd_Click()
Call koneksi
Call bersih
Call aktif
rstanggaltest.Open "select*from tanggaltest order by no_kode desc", KON
With rstanggaltest
If .BOF And .EOF Then
nokode.Text = "T" + "001"
Else
nokode.Text = "T" + Right(Str(Val(Right(.Fields("no_kode"), 3)) + 1001), 3)
End If
End With
tgl1.SetFocus
cmdsave.Enabled = True
cmdcancel.Enabled = True
cmddelete.Enabled = False
End Sub
Call koneksi
Call bersih
Call aktif
rstanggaltest.Open "select*from tanggaltest order by no_kode desc", KON
With rstanggaltest
If .BOF And .EOF Then
nokode.Text = "T" + "001"
Else
nokode.Text = "T" + Right(Str(Val(Right(.Fields("no_kode"), 3)) + 1001), 3)
End If
End With
tgl1.SetFocus
cmdsave.Enabled = True
cmdcancel.Enabled = True
cmddelete.Enabled = False
End Sub
- cmdsave :
Private Sub cmdsave_Click()
Call koneksi
rstanggaltest.Open "insert into tanggaltest values('" & nokode & "','" & tgl1 & "','" & tgl2 & "')", KON
MsgBox "Data Sudah Tersimpan", vbInformation
Call tampil
Call nonaktif
End Sub
Call koneksi
rstanggaltest.Open "insert into tanggaltest values('" & nokode & "','" & tgl1 & "','" & tgl2 & "')", KON
MsgBox "Data Sudah Tersimpan", vbInformation
Call tampil
Call nonaktif
End Sub
- cmdcancel :
Private Sub cmdcancel_Click()
bersih
tgl1.SetFocus
Call nonaktif
End Sub
bersih
tgl1.SetFocus
Call nonaktif
End Sub
-cmdedit
Private Sub cmdedit_Click()
Call koneksi
rstanggaltest.Open "select*from tanggaltest where no_kode='" & tcari.Text & "'", KON
With rstanggaltest
nokode.Text = .Fields("no_kode")
tgl1.Text = .Fields("tanggaltest1")
tgl2.Text = .Fields("tanggaltest2")
End With
nokode.Enabled = False
tgl1.SetFocus
cmdupdate.Enabled = True
cmddelete.Enabled = True
cmdcancel.Enabled = False
End Sub
Call koneksi
rstanggaltest.Open "select*from tanggaltest where no_kode='" & tcari.Text & "'", KON
With rstanggaltest
nokode.Text = .Fields("no_kode")
tgl1.Text = .Fields("tanggaltest1")
tgl2.Text = .Fields("tanggaltest2")
End With
nokode.Enabled = False
tgl1.SetFocus
cmdupdate.Enabled = True
cmddelete.Enabled = True
cmdcancel.Enabled = False
End Sub
-cmdupdate :
Private Sub cmdupdate_Click()
Call koneksi
rstanggaltest.Open "update tanggaltest set tanggaltest1='" & tgl1 & "',tanggaltest2='" & tgl2 & "' where no_kode='" & nokode.Text & "'", KON
MsgBox "Data Berhasil di Update", vbInformation, "Info"
bersih
Call tampil
cmdupdate.Enabled = False
cmdedit.Enabled = False
cmdadd.Enabled = True
End Sub
Call koneksi
rstanggaltest.Open "update tanggaltest set tanggaltest1='" & tgl1 & "',tanggaltest2='" & tgl2 & "' where no_kode='" & nokode.Text & "'", KON
MsgBox "Data Berhasil di Update", vbInformation, "Info"
bersih
Call tampil
cmdupdate.Enabled = False
cmdedit.Enabled = False
cmdadd.Enabled = True
End Sub
- cmddelete :
Private Sub cmddelete_Click()
Call koneksi
a = MsgBox("Yakin Ingin Hapus Data ini?", vbQuestion + vbYesNo, "tanya")
If a = vbYes Then
rstanggaltest.Open "delete from tanggaltest where no_kode='" & tcari.Text & "'", KON
bersih
tcari.Text = ""
End If
End Sub
- tcari (ubah declarations nya ke "change")
Private Sub tcari_Change()
Call koneksi
rstanggaltest.Open "select*from tanggaltest where no_kode like '" & tcari.Text & "'", KON
If Not tcari.Text = "" Then
Set grid.DataSource = rstanggaltest
Else
Call tampil
End If
cmdedit.Enabled = True
cmdadd.Enabled = False
cmdsave.Enabled = False
End Sub
Call koneksi
rstanggaltest.Open "select*from tanggaltest where no_kode like '" & tcari.Text & "'", KON
If Not tcari.Text = "" Then
Set grid.DataSource = rstanggaltest
Else
Call tampil
End If
cmdedit.Enabled = True
cmdadd.Enabled = False
cmdsave.Enabled = False
End Sub
- exit :
Private Sub EXIT_Click()
a = MsgBox("Yakin Keluar", vbCritical + vbYesNo, "INFO")
If a = vbYes Then
End
End If
End Sub
a = MsgBox("Yakin Keluar", vbCritical + vbYesNo, "INFO")
If a = vbYes Then
End
End If
End Sub
- bmenu :
Private Sub Command1_Click()
fmenu.Show
End Sub
fmenu.Show
End Sub
Update Contact :
No Wa/Telepon (puat) : 085267792168
No Wa/Telepon (fajar) : 085369237896
Email : Fajarudinsidik@gmail.com
No Wa/Telepon (puat) : 085267792168
No Wa/Telepon (fajar) : 085369237896
Email: Fajarudinsidik@gmail.com
atau Kirimkan Private messanger melalui email dengan klik tombol order dibawah ini :