15
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

Visual Basic

Embed Size (px)

Citation preview

Page 1: Visual Basic

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"

Page 2: Visual Basic

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

Page 3: Visual Basic

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

Page 4: Visual Basic

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

Page 5: Visual Basic

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:

Page 6: Visual Basic

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

Page 7: Visual Basic

Option2.Value = False

Check1.Value = False

End Sub

2. Program Entri Data Matakuliah

Page 8: Visual Basic

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()

Page 9: Visual Basic

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

Page 10: Visual Basic

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

Page 11: Visual Basic

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

Page 12: Visual Basic

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 = ""

Page 13: Visual Basic

End Sub

“Terimakasih”

Page 14: Visual Basic

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