You are on page 1of 7

1.

Database
Nama Tabel : Database_Nilai
Field Name Data Type Field Size
Matematika Number -
Biologi Number -
Kimia Number -
Fisika Number -
Nilai_Akhir Number -
Hasil Short Text 15
FORM
Konfigurasi Form
No Komponen Properties Nilai
1 Label1 Caption Nilai Akhir Ujian
2 Label2 Caption Matematika
3 Label3 Caption Biologi
4 Label4 Caption Fisika
5 Label5 Caption Kimia
6 Label6 Caption Nilai Akhir
7 Label7 Caption (Dikosongkan)
8 Text1 Text (Dikosongkan)
9 Text2 Text (Dikosongkan)
10 Text3 Text (Dikosongkan)
11 Text4 Text (Dikosongkan)
12 Text5 Text (Dikosongkan)
13 Frame Caption Menu
Name CmdHitung
14 CommandButton1
Caption Hitung
Name CmdTambah
15 CommandButton2
Caption Tambah
Name CmdHapus
16 CommandButton3
Caption Hapus
Name CmdKeluar
17 CommandButton4
Caption Keluar
Name Adodc1
18 Adodc
RecordSource Database_Nilai
19 DataGrid DataSource Adodc1
2. Koneksi Adodc Ke Database
a. Klik Kanan Adodc => ADODC Properties

b. Klik Build

c. Pilih Provider = Microsoft.Jet.OLEDB.4.0 => Next => Pilih Database => Test
Connection => OK
Option Explicit
Private Sub cmdHitung_Click()
If Text1.Text = "" Then
MsgBox " Nilai belum diisi!", vbInformation + vbOKOnly, "Perhatian"
Text1.SetFocus
ElseIf Text2.Text = "" Then
MsgBox " Nilai belum diisi!", vbInformation + vbOKOnly, "Perhatian"
Text2.SetFocus
ElseIf Text3.Text = "" Then
MsgBox " Nilai belum diisi!", vbInformation + vbOKOnly, "Perhatian"
Text3.SetFocus
ElseIf Text4.Text = "" Then
MsgBox " Nilai belum diisi!", vbInformation + vbOKOnly, "Perhatian"
Text4.SetFocus
Else
Text5.Text = (Val(Text1) + Val(Text2) + Val(Text3) + Val(Text4)) / 4
CmdTambah.Enabled = True
End If

If Text5.Text = "" Then


Label7.Enabled = False
ElseIf Text5 >= 55 Then
Label7 = "LULUS"
Else
Label7 = "TIDAK LULUS"
End If
End Sub
Private Sub Form_Load()
CmdTambah.Enabled = False
End Sub
Private Sub CmdTambah_Click()
Adodc1.Recordset.AddNew
Adodc1.Recordset!Matematika = Text1
Adodc1.Recordset!Biologi = Text2
Adodc1.Recordset!Kimia = Text3
Adodc1.Recordset!Fisika = Text4
Adodc1.Recordset!Nilai_Akhir = Text5
Adodc1.Recordset!Hasil = Label7
Adodc1.Recordset.Update
Adodc1.Refresh
DataGrid1.Refresh
End Sub
Private Sub cmdKeluar_Click()
Unload Me
End Sub
Private Sub CmdHapus_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Label7 = ""
CmdTambah.Enabled = False
End Sub

You might also like