PENGUJIAN DAN HASIL
4.7 Pengujian Program Software Visual Basic
Untuk memasukkan data ke komputer dan disimpan di Ms. Acces. Dengan program:
Public Class Form_Cetak
Private Sub Form_Cetak_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Private Sub Form_Editor_Load(sender As Object, e As EventArgs) Handles MyBase.Load
TT.SetToolTip(btn_simpan, "Simpan") TT.SetToolTip(btn_hapus, "Hapus")
TT.SetToolTip(btn_pilih_gambar, "Pilih Gambar") TT.SetToolTip(btn_hapus_gambar, "Hapus Gambar") Call Bersihkan()
Call Koneksi()
txt_kode.Text = Barcode End Sub
Private Sub btn_simpan_Click(sender As Object, e As EventArgs) Handles btn_simpan.Click
If txt_kode.Text = "" Then txt_kode.Focus() : TT.Show("Input Kode", txt_kode) : Exit Sub
If Edit = False Then Try
Call Simpan()
MessageBox.Show("Berhasil Di Simpan", "Pesan",
Private Sub btn_hapus_Click(sender As Object, e As EventArgs) Handles btn_hapus.Click
If txt_kode.Text = "" Then txt_kode.Focus() : TT.Show("Input Kode", txt_kode) : Exit Sub
Try
Call Hapus()
Catch ex As Exception
MessageBox.Show("Proses Gagal", "Pesan", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try End Sub
Private Sub btn_pilih_gambar_Click(sender As Object, e As EventArgs) Handles
pb_gambar.Image = Image.FromFile(Application.StartupPath & "\Gambar\"
& SGambar) End If End Sub
Private Sub btn_hapus_gambar_Click(sender As Object, e As EventArgs) Handles btn_hapus_gambar.Click
'SGambar = "Temp.png"
'pb_gambar.Image = Image.FromFile(Application.StartupPath & "\Gambar\" &
SGambar) End Sub
Private Sub Bersihkan() SGambar = "Temp.png"
'pb_gambar.Image = Image.FromFile(Application.StartupPath & "\Gambar\" &
SGambar)
txt_kondisi.Clear() txt_keterangan.Clear() txt_kode.Focus() End Sub
Private Sub txt_kode_TextChanged(sender As Object, e As EventArgs) Handles txt_kode.TextChanged
'Edit = Cek_Barang() End Sub
Function Cek_Barang() As Boolean
CMD = New OleDbCommand("SELECT * FROM Barang WHERE Kode = '"
& txt_kode.Text & "'", CONN) DR = CMD.ExecuteReader
'pb_gambar.Image = Image.FromFile(Application.StartupPath & "\Gambar\"
& SGambar) Return True End If
SGambar = "Temp.png"
'pb_gambar.Image = Image.FromFile(Application.StartupPath & "\Gambar\" &
SGambar)
txt_nama.Clear() txt_jumlah.Clear()
txt_tahun.Value = Date.Now()
"','" & txt_nama.Text & "','" _
& txt_jumlah.Text & "','" & txt_tahun.Text & "','" & txt_gedung.Text & "','"
"','" & txt_nama.Text & "','" _
& txt_jumlah.Text & "','" & txt_tahun.Text & "','" & txt_gedung.Text & "','"
Application.StartupPath & "\Gambar\" & txt_kode.Text &
CMD.ExecuteNonQuery()
If MessageBox.Show("Yakin Akan Di Hapus ?", "Konfirmasi", MessageBoxButtons.YesNo, MessageBoxIcon.Question) =
Windows.Forms.DialogResult.Yes Then
CMD = New OleDbCommand("DELETE FROM Barang WHERE Kode = '"
& txt_kode.Text & "'", CONN) CMD.ExecuteNonQuery()
MessageBox.Show("Berhasil Di Hapus", "Pesan", MessageBoxButtons.OK, MessageBoxIcon.Information)
Call Bersihkan()
Call Form_Home.Ambil_Data() End If
End Sub
Private Sub txt_jumlah_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txt_jumlah.KeyPress
If Not ((e.KeyChar >= "0" And e.KeyChar <= "9") Or e.KeyChar = vbBack) Then e.Handled() = True
End Sub
Private Sub GroupBox5_Enter(sender As Object, e As EventArgs) Handles GroupBox5.Enter
End Sub
Private Sub GroupBox4_Enter(sender As Object, e As EventArgs) Handles GroupBox4.Enter
End Sub
Private Sub Label4_Click(sender As Object, e As EventArgs) End Sub
Private Sub Label1_Click(sender As Object, e As EventArgs) End Sub
Private Sub Label10_Click(sender As Object, e As EventArgs) End Sub
Private Sub Label11_Click(sender As Object, e As EventArgs) End Sub
Private Sub txt_deskripsi_TextChanged(sender As Object, e As EventArgs) Handles txt_deskripsi.TextChanged
Delegate Sub SetTextCallBack(ByVal [text] As String) Public Sub New()
Private Sub FormClosingEventCancle_Closing(sender As Object, e As System.ComponentModel.CancelEventArgs)
Dim Konfirmasi As DialogResult
Konfirmasi = MessageBox.Show("Anda Ingin keluar ?", "Konfirmasi", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
Private Sub Form_Home_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Call Ambil_Data() End Sub
Private Sub LogoutToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles LogoutToolStripMenuItem.Click
Dispose()
Form_Login.Show() End Sub
Private Sub ExitToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ExitToolStripMenuItem.Click
Close() End Sub
Private Sub TambahToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles TambahToolStripMenuItem.Click
Form_Editor.Barcode = ""
Form_Editor.ShowDialog() End Sub
Private Sub ScannerToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ScannerToolStripMenuItem.Click
Form_Scanner.ShowDialog()
End Sub
Public Sub Ambil_Data() Call Koneksi()
DA = New OleDbDataAdapter("Select Kode, Nama, NIK, `Tanggal`,KET, IMT, Tinggi, Berat, Status FROM Barang", CONN)
DS = New DataSet IMT, Tinggi, Berat, Status FROM Barang WHERE Kode like '%" & txt_cari.Text &
"%' OR Nama like '%" & txt_cari.Text & "%'", CONN) DS = New DataSet
For i = 0 To dgv.Rows.Count - 1
dgv.Rows(i).Cells(0).Value = i + 1 & "."
Next End Sub
Private Sub txt_cari_TextChanged(sender As Object, e As EventArgs) Handles txt_cari.TextChanged
Call Cari_Barang() End Sub
Private Sub btn_clear_Click(sender As Object, e As EventArgs) Handles btn_clear.Click
Call Ambil_Data() End Sub
Private Sub CetakToolStripMenuItem1_Click(sender As Object, e As EventArgs) Handles CetakToolStripMenuItem1.Click
Private Sub dgv_CellDoubleClick(sender As Object, e As DataGridViewCellEventArgs) Handles dgv.CellDoubleClick
Private Sub dgv_Sorted(sender As Object, e As EventArgs) Handles dgv.Sorted For i = 0 To dgv.Rows.Count - 1
dgv.Rows(i).Cells(0).Value = i + 1 & "."
Next End Sub
Private Sub SP_DataReceived(sender As Object, e As
Ports.SerialDataReceivedEventArgs) Handles SP.DataReceived ReceivedText(SP.ReadExisting())
End Sub
Private Sub ReceivedText(ByVal text As String) text = text.Trim
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Private Sub MenuStrip1_ItemClicked(sender As Object, e As ToolStripItemClickedEventArgs) Handles MenuStrip1.ItemClicked End Sub
Private Sub BARANGToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles BARANGToolStripMenuItem.Click
End Sub End Class
Imports System.Data.OleDb Public Class Form_Login
Private Sub Form_Login_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Call Koneksi() Call Bersihkan() End Sub
Private Sub btn_login_Click(sender As Object, e As EventArgs) Handles btn_login.Click
If txt_username.Text = "" Then TT.Show("Masukkan Username", txt_username) : txt_username.Focus() : Exit Sub
If txt_password.Text = "" Then TT.Show("Masukkan Password", txt_password) : txt_password.Focus() : Exit Sub
Call Cek_Admin()
= '" & txt_username.Text & "' AND Password = '" & txt_password.Text & "'", CONN)
DR = CMD.ExecuteReader Periksa Kembali.", "Pesan", MessageBoxButtons.OK, MessageBoxIcon.Error) txt_username.Focus()
End If End Sub
Private Sub txt_username_TextChanged(sender As Object, e As EventArgs) Handles txt_username.TextChanged
Private Sub FormClosingEventCancle_Closing(sender As Object, e As System.ComponentModel.CancelEventArgs)
Hide() End Sub
Private Sub Form_Scanner_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Call Setting_Scanner() End Sub
Private Sub Setting_Scanner() cb_portname.Items.Clear()
Dim ports As String() = SerialPort.GetPortNames() cb_portname.Items.AddRange(ports)
End Sub
Private Sub btn_refresh_Click(sender As Object, e As EventArgs) Handles btn_refresh.Click
Call Setting_Scanner() End Sub
Private Sub btn_connect_Click(sender As Object, e As EventArgs) Handles btn_connect.Click
Form_Home.txt_scanner.Text = "Disconnect"
End If End Sub End Class
Dengan data yang diperoleh sebagai berikut:
Gambar 4.2 Data base hasil
Persen kesalahan berat badan dan tinggi badan:
Persentase kesalahan =
Tabel 4.2 Persen kesalahan Nama
Berat Badan Tinggi Badan
Sebenarnya
Sehingga diperoleh kesimpulan ralat yang diperoleh dari hasil penelitian dan percobaan dikategorikan baik.
Gambar 4.3 Data pada visual basic