visual basic
TRANSCRIPT
TUGAS VISUAL BASIC (VB)
1. Program Entri Data Mahasiswa
Koding untuk Tombol Simpan:
Private Sub Command2_Click()
Adodc1.Recordset.AddNew
Adodc1.Recordset!nim = Text1.Text
Adodc1.Recordset!nama = Text2.Text
Adodc1.Recordset!tempat_lahir = Text3.Text
Adodc1.Recordset!tgl_lahir = Format(DTPicker1.Value, "YYYY-MM-DD")
If Option1 = True Then
Adodc1.Recordset!jenis_kelamin = "laki-laki"
Else
Adodc1.Recordset!jenis_kelamin = "perempuan"
End If
Adodc1.Recordset!prodi = Combo1
If Check1 = True Then
Adodc1.Recordset!kelas = "reguler"
Else
Adodc1.Recordset!kelas = "non reguler"
End If
Adodc1.Recordset.Update
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Combo1.Text = ""
Koding untuk tombol cari:
Private Sub Command1_Click()
Dim CARI As String
CARI = "nim='" & Text1.Text & "'"
Adodc1.Recordset.MoveFirst
Adodc1.Recordset.Find CARI
If Not Adodc1.Recordset.EOF Then
Text1.Text = Adodc1.Recordset!nim
Text2.Text = Adodc1.Recordset!nama
Text3.Text = Adodc1.Recordset!tempat_lahir
DTPicker1.Value = Adodc1.Recordset!tgl_lahir
Combo1.Text = Adodc1.Recordset!prodi
MsgBox "data sudah ada"
Dim kelas As Integer
Dim jenis_kelamin As Integer
If Adodc1.Recordset!kelas = "reguler" Then
Check1.Value = 1
Else
Check1.Value = 0
End If
If Adodc1.Recordset!jenis_kelamin = "laki-laki" Then
Option1.Value = True
Else
Option2.Value = True
End If
End If
End Sub
Koding untuk tombol hapus:
Private Sub Command3_Click()
Dim CARI As String
CARI = "nim='" & Text1.Text & "'"
Adodc1.Recordset.Find CARI
If Not Adodc1.Recordset.EOF Then
Text1.Text = Adodc1.Recordset!nim
Text2.Text = Adodc1.Recordset!nama
Text3.Text = Adodc1.Recordset!tempat_lahir
DTPicker1.Value = Adodc1.Recordset!tgl_lahir
Combo1 = Adodc1.Recordset!prodi
If MsgBox("Hapus Data ?", vbQuestion + vbYesNo) = vbYes Then
Adodc1.Recordset.Delete
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Combo1.Text = ""
MsgBox "Data Mahasiswa Sudah di Hapus !!!"
End If
End If
End Sub
Koding untuk tombol Edit:
Private Sub Command4_Click()
pesan = MsgBox("Anda Yakin Data Ini Akan diEdit..??", vbYesNo, "Info")
If pesan = vbYes Then
Adodc1.Recordset!nama = Text2.Text
Adodc1.Recordset!tempat_lahir = Text3.Text
Adodc1.Recordset!tgl_lahir = DTPicker1.Value
Adodc1.Recordset!prodi = Combo1
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Combo1.Text = ""
If Option1 = True Then
Adodc1.Recordset!jenis_kelamin = "laki-laki"
Else
Adodc1.Recordset!jenis_kelamin = "perempuan"
End If
If Check1 = vbChecked Then
Adodc1.Recordset!kelas = "reguler"
Else
Adodc1.Recordset!kelas = "non reguler"
End If
MsgBox "Data MAhasiswa Sudah diEdit !!!"
End If
Option1.Value = False
Option2.Value = False
Check1.Value = False
End Sub
2. Program Entri Data Matakuliah
Koding untuk tombol Simpan:
Private Sub Command2_Click()
Adodc1.Recordset.AddNew
Adodc1.Recordset!kode_mtk = Text1.Text
Adodc1.Recordset!nama_mtk = Text2.Text
Adodc1.Recordset!semester = Combo1
Adodc1.Recordset!sks = Combo2
Adodc1.Recordset.Update
End Sub
Koding untuk tombol Cari
Private Sub Command1_Click()
Dim CARI As String
CARI = "kode_mtk='" & Text1.Text & "'"
Adodc1.Recordset.MoveFirst
Adodc1.Recordset.Find CARI
If Not Adodc1.Recordset.EOF Then
Text1.Text = Adodc1.Recordset!kode_mtk
Text2.Text = Adodc1.Recordset!nama_mtk
Combo1.Text = Adodc1.Recordset!semester
Combo2.Text = Adodc1.Recordset!sks
'Command2.Enabled = False
MsgBox "data sudah ada"
End If
End Sub
Koding untuk tombol Hapus:
Private Sub Command3_Click()
Dim CARI As String
CARI = "kode_mtk='" & Text1.Text & "'"
Adodc1.Recordset.Find CARI
If Not Adodc1.Recordset.EOF Then
Text1.Text = Adodc1.Recordset!kode_mtk
Text2.Text = Adodc1.Recordset!nama_mtk
Combo1 = Adodc1.Recordset!semester
Combo2 = Adodc1.Recordset!sks
If MsgBox("Hapus Data ?", vbQuestion + vbYesNo) = vbYes Then
Adodc1.Recordset.Delete
'bersih_layar
End If
End If
End Sub
Koding untuk tombol Edit:
Private Sub Command4_Click()
pesan = MsgBox("Anda Yakin Data Ini Akan diEdit..??", vbYesNo, "Info")
If pesan = vbYes Then
Adodc1.Recordset!nama_mtk = Text2.Text
Adodc1.Recordset!semester = Combo1.Text
Adodc1.Recordset!sks = Combo2.Text
Adodc1.Recordset.Update
End If
End Sub
Koding untuk tombol Clear:
Private Sub Comman5_Click()
Text1.Text = ""
Text2.Text = ""
Combo1.Text = ""
Combo2.Text = ""
End Sub
“Terimakasih”
TUGAS PEMROGRAMAN VISUAL BASIC II
D
I
S
U
S
U
N
OLEH
MUHAMMAD ZUHDI
NIM: 091000757201145
SISTEM INFORMASI
FAKULTAS ILMU KOMPUTER
UNIVERSITAS LANCANG KUNING