Anda di halaman 1dari 15

LAPORAN SEMENTARA

PRAKTIKUM PEMROGRAMAN KOMPUTER


BAB VII
PROCEDURE, FUNCTION, AND MODULAR

Disusun oleh:
PLUG H

BAGUS WIJANARKO
122220110

LABORATORIUM KOMPUTASI
PROGRAM STUDI TEKNIK INDUSTRI
JURUSAN TEKNIK INDUSTRI
FAKULTAS TEKNIK INDUSTRI
UNIVERSITAS PEMBANGUNAN NASIONAL “VETERAN”
YOGYAKARTA
2023
LEMBAR ORISINALITAS
Saya yang bertanda tangan dibawah ini:
Nama : Bagus Wijanarko
NIM : 122220110
menyatakan bahwa Laporan Praktikum Pemrograman Komputer Bab VII ini
merupakan hasil karya saya sendiri.
Apabila pernyataan ini terbukti tidak benar, saya bersedia untuk
mempertanggungjawabkan dan menerima sanksi sesuai hukum yang berlaku.
Demikian pernyataan ini saya buat dengan sebenar-benarnya dan tanpa paksaan
dari pihak manapun.

Yogyakarta, 16 April 2023


Yang menyatakan,

Bagus Wijanarko
NIM 122220110
BAB VII
PROCEDURE, FUNCTION, AND MODULAR
7.1 Tujuan Praktikum
Tujuan praktikum pada Bab VII ini adalah:
1. Memahami dan mengenal Procedure, Function dan Module.
2. Membuat aplikasi sederhana dengan menggunakan Procedure, Function, dan
Module.
7.2 Dasar Teori
7.2.1 Procedure
Procedure merupakan blok kode yang mempunyai nama dan berisi perintah yang
dapat dipanggil suatu waktu. Artinya, hanya sekali dibuat yang kemudian dipanggil
berkali-kali sesuai dengan kebutuhan. Pemanggilan procedure yang masih dalam
satu kelas (class) atau modul (module) dapat dilakukan dengan kata kunci Me.
Procedure dapat menerima argument melalui nilai (by value) atau juga reference
(by reference). Jika menggunakan by value, nilai pada argument tidak berubah.
Sedangkan jika menggunakan by reference, nilai argument yang digunakan dapat
berubah sesuai dengan perintah dalam procedure. Secara default, argument
dimasukkan melalui nilai (by value) dapat menggunakan kata kunci ByVal dan
ByRef untuk By Reference.
7.2.2 Function (Fungsi)
Fungsi mempunyai banyak kemiripan dengan sub procedure. Bedanya, fungsi
selalu mengembalikan nilai (return value). Perbedaan antara fungsi dengan
procedure hanyalah pada pengembalian nilai saja (return value). Sebagai contoh
penggunaan argument berupa nilai (by value) dan reference (by reference).
Pengembalian nilai dapat dilakukan dengan menggunakan operator assignment “=”
pada fungsi atau biasanya dengan perintah return.
7.2.3 Modul (Module)
Modul merupakan bagian yang sengaja dipisahkan untuk memudahkan
pemrograman. Dalam module dapat dimasukkan procedure dan fungsi dan
kemudian digunakan oleh beberapa form.

Laporan Praktikum Pemrograman Komputer 2023 VII-1


− Umumnya modul dideklarasikan secara public agar dapat digunakan di dalam
kode di manapun.
− Modul dapat diisi dengan main procedure yang akan dijalankan pertama kali saat
program dimulai.
− Modul merupakan salah satu argumentasi code reuse yang bertujuan agar
program lebih efesien.
7.3 Flowchart
Berikut ini merupakan gambar flowchart program perhitungan biaya perbaikan
mesin dapat dilihat pada Gambar 7.1

1
Mulai

Input :
Merk mesin,
keluhan

Penggantian Part =
Jumlah Part*Harga Part

Total Biaya =
Penggantian Part + Jasa

Output :
biaya perbaikan

6
Selesai

Gambar 7.1 Flowchart program perhitungan perbaikan biaya mesin


Laporan Praktikum Pemrograman Komputer 2023 VII-2
7.4 Form
7.4.1 Form 1 berupa identifikasi kerusakan mesin dapat dilihat pada Gambar 7.2

Gambar 7.2 Form identifikasi kerusakan mesin


Properties toolbox form 1 dapat dilihat pada Tabel 7.1
Tabel 7.1 Properties Toolbox Form 1
Object Properties Nilai
Name Form1
Form 1 Back Color Control
Text Identifikasi Kerusakan
Name Label1
Label 1 Font Microsoft Sans Serif 8.25pt
Text Merk Mesin
Name Label2
Label 2 Font Microsoft Sans Serif 8.25pt
Text Keluhan
Name CheckBox1
Check Box 1 Font Microsoft Sans Serif 8.25pt
Text Selang Pecah/Bocor
Name CheckBox2
Check Box 2 Font Microsoft Sans Serif 8.25pt
Text Tidak Bisa Berputar
Name CheckBox3
Check Box 3 Font Microsoft Sans Serif 8.25pt
Text Putaran Tidak Kuat
Name CheckBox4
Check Box 4 Font Microsoft Sans Serif 8.25pt
Text Penjepit Selip
Name CheckBox5
Check Box 5 Font Microsoft Sans Serif 8.25pt
Text Bead Breaker Tidak Berfungsi

Laporan Praktikum Pemrograman Komputer 2023 VII-3


Tabel 7.1 Properties Toolbox Form 1 (lanjutan)
Object Properties Nilai
Name CheckBox6
Check Box 6 Font Microsoft Sans Serif 8.25pt
Text Kehilangan Part
Name CheckBox7
Check Box 7 Font Microsoft Sans Serif 8.25pt
Text Keluhan Lain
Text Box 1 Name txtpart
Text Box 2 Name txtlain
Name Button 1
Button 1 Back Color White
Text NEXT
7.4.2 Form 2 berupa estimasi biaya perbaikan mesin dapat dilihat pada Gambar 7.3

Gambar 7.3 Form perhitungan estimasi biaya


Properties toolbox form 2 dapat dilihat pada Tabel 7.2
Tabel 7.2 Properties Toolbox Form 2
Object Properties Nilai
Name Form2
Form 1 Back Color Control
Text Rincian Biaya
Name Label1
Label 1 Font Microsoft Sans Serif 20pt, Bold
Text ESTIMASI BIAYA
Name Label2
Label 2 Font Microsoft Sans Serif 9.75pt
Text Penggantian Part

Laporan Praktikum Pemrograman Komputer 2023 VII-4


Tabel 7.2 Properties Toolbox Form 2 (lanjutan)
Object Properties Nilai
Name Label3
Label 3 Font Microsoft Sans Serif 9.75pt
Text Keluhan
Name Label4
Label 4 Font Microsoft Sans Serif 8.25pt
Text Estimasi Penggantian Part
Name CheckBox1
Check Box 1 Font Microsoft Sans Serif 8.25pt
Text Oring 4x10
Name CheckBox2
Check Box 2 Font Microsoft Sans Serif 8.25pt
Text Oring 142
Name CheckBox3
Check Box 3 Font Microsoft Sans Serif 8.25pt
Text Sulingan
Name CheckBox4
Check Box 4 Font Microsoft Sans Serif 8.25pt
Text Coupler
Name CheckBox5
Check Box 5 Font Microsoft Sans Serif 8.25pt
Text Seal DK
Name CheckBox6
Check Box 6 Font Microsoft Sans Serif 8.25pt
Text Seal Bead Breaker
Name CheckBox7
Check Box 7 Font Microsoft Sans Serif 8.25pt
Text Selang
Name CheckBox8
Check Box 8 Font Microsoft Sans Serif 8.25pt
Text Shaft Seal 20*30*7
Name CheckBox9
Check Box 9 Font Microsoft Sans Serif 8.25pt
Text Part Lain
Text Box 1 Name TextBox1
Text Box 2 Name TextBox2
Text Box 3 Name TextBox3
Text Box 4 Name TextBox4
Text Box 5 Name TextBox5
Text Box 6 Name TextBox6
Text Box 7 Name TextBox7
Text Box 8 Name TextBox8
Text Box 9 Name TextBox9
Items 2000
Text Box 10
Read Only True
Items 3000
Text Box 11
Read Only True

Laporan Praktikum Pemrograman Komputer 2023 VII-5


Tabel 7.2 Properties Toolbox Form 2 (lanjutan)
Object Properties Nilai
Items 150000
Text Box 12
Read Only True
Items 120000
Text Box 13
Read Only True
Items 75000
Text Box 14
Read Only True
Items 95000
Text Box 15
Read Only True
Items 4500
Text Box 16
Read Only True
Items 16000
Text Box 17
Read Only True
Name txttotal
Text Box 18
Read Only True
Name btnhitung
Button 1 Back Color White
Text HITUNG
Name Button2
Button 2 Back Color White
Text NEXT
Name Button3
Button 3 Back Color White
Text BACK
List Box 1 Name ListBox1
7.4.3 Form 3 berupa konfirmasi perbaikan mesin dapat dilihat pada Gambar 7.4

Gambar 7.4 Form konfirmasi perbaikan mesin

Laporan Praktikum Pemrograman Komputer 2023 VII-6


Properties toolbox form 3 dapat dilihat pada Tabel 7.3
Tabel 7.2 Properties Toolbox Form 3
Object Properties Nilai
Name Form3
Form 1 Back Color Control
Text Konfirmasi
Name Label1
Label 1 Font Microsoft Sans Serif 8.25pt
Text Merk Mesin
Name Label2
Label 2 Font Microsoft Sans Serif 8.25pt
Text Keluhan
Name Label3
Label 3 Font Microsoft Sans Serif 8.25pt
Text Estimasi Penggantian Part
Name Label4
Label 4 Font Microsoft Sans Serif 8.25pt
Text Jasa Perbaikan
Name Label5
Label 5 Font Microsoft Sans Serif 8.25pt
Text Total Biaya
Name txtmerk
Text Box 1
Read Only True
Name txttotal
Text Box 2
Read Only True
Text Box 3 Name txtjasa
Name txtall
Text Box 4
Read Only True
Name CheckBox1
Check Box 1 Font Microsoft Sans Serif 8.25pt
Text Setuju Dengan Biaya Perbaikan
Name btnhitung
Button 1 Back Color White
Text HITUNG
List Box 1 Name List Box 1
7.5 Listing Program
7.5.1 Listing Program Form 1
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
If CheckBox1.Checked = True Then
Form2.ListBox1.Items.Add(CheckBox1.Text)
ElseIf CheckBox2.Checked = True Then

Laporan Praktikum Pemrograman Komputer 2023 VII-7


Form2.ListBox1.Items.Add(CheckBox2.Text)
ElseIf CheckBox3.Checked = True Then
Form2.ListBox1.Items.Add(CheckBox3.Text)
ElseIf CheckBox4.Checked = True Then
Form2.ListBox1.Items.Add(CheckBox4.Text)
ElseIf CheckBox5.Checked = True Then
Form2.ListBox1.Items.Add(CheckBox5.Text)
ElseIf CheckBox6.Checked = True Then
Form2.ListBox1.Items.Add(CheckBox6.Text & ":" & TextBox2.Text)
ElseIf CheckBox7.Checked = True Then
Form2.ListBox1.Items.Add(CheckBox7.Text & ":" & TextBox3.Text)
End If
If CheckBox1.Checked = False And CheckBox2.Checked = False And
CheckBox3.Checked = False And CheckBox4.Checked = False And
CheckBox5.Checked = False And CheckBox6.Checked = False And
CheckBox7.Checked = False And TextBox1.Text = "" Then
Call pesan1()
Else Form2.Show()
Me.Hide()
End If
End Sub
End Class
7.5.2 Listing Program Form 2
Public Class Form2
Dim total As Double
Dim cb As CheckBox()
Dim harga As TextBox()
Dim jumlah As TextBox()
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Laporan Praktikum Pemrograman Komputer 2023 VII-8


cb = New CheckBox() {CheckBox1, CheckBox2, CheckBox3, CheckBox4,
CheckBox5, CheckBox6, CheckBox7, CheckBox8, CheckBox9}
harga = New TextBox() {TextBox10, TextBox11, TextBox12, TextBox13,
TextBox14, TextBox15, TextBox16, TextBox17}
jumlah = New TextBox() {TextBox1, TextBox2, TextBox3, TextBox4,
TextBox5, TextBox6, TextBox7, TextBox8}
End Sub
Private Sub btnhitung_Click(sender As Object, e As EventArgs) Handles
btnhitung.Click
Dim i As Integer
total = 0
For i = 0 To 8
If cb(i).Checked = True Then
total = total + (Val(harga(i).Text) * Val(jumlah(i).Text))
End If
Next
txttotal.Text = total
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles
Button2.Click
If CheckBox1.Checked = False And CheckBox2.Checked = False And
CheckBox3.Checked = False And CheckBox4.Checked = False And
CheckBox5.Checked = False And CheckBox6.Checked = False And
CheckBox7.Checked = False And CheckBox8.Checked = False And
CheckBox9.Checked = False And txttotal.Text = "" Then
Call pesan1()
Else Form3.Show()
Me.Hide()
End If
End Sub

Laporan Praktikum Pemrograman Komputer 2023 VII-9


Private Sub Button3_Click(sender As Object, e As EventArgs) Handles
Button3.Click
Form1.Show()
Me.Hide()
End Sub
End Class
7.5.3 Listing Program Form 3
Public Class Form3
Private Sub Form3_Load(sender As Object, e As EventArgs) Handles
MyBase.Load
txtmerk.Text = Form1.TextBox1.Text
ListBox1.Items.Add(Form2.ListBox1.Items)
txttotal.Text = Form2.txttotal.Text
End Sub
Private Sub btnhitung_Click(sender As Object, e As EventArgs) Handles
btnhitung.Click
If CheckBox1.Checked = False Then
Call pesan2()
Else txtall.Text = CInt(txttotal.Text) + CInt(txtjasa.Text)
End If
End Sub
End Class
7.5.4 Listing Module
Module Module1
Dim A%
Dim B%
Sub pesan1()
MessageBox.Show("Mohon inputkan data terlebih dahulu!", "Konfirmasi",
MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub
Sub pesan2()

Laporan Praktikum Pemrograman Komputer 2023 VII-10


MessageBox.Show("Anda belum menyetujui!", "Konfirmasi",
MessageBoxButtons.OK, MessageBoxIcon.Warning)
End Sub
Function penjumlahan()
penjumlahan = A + B
End Function
Function Perkalian()
Perkalian = A * B
End Function
End Module
7.6 Running Program
7.6.1 Running program form 1 dapat dilihat pada Gambar 7.5

Gambar 7.5 Running program pada form 1


7.6.2 Running program form 2 dapat dilihat pada Gambar 7.6

Laporan Praktikum Pemrograman Komputer 2023 VII-11


Gambar 7.6 Running program pada form 2
7.6.3 Running program form 3 dapat dilihat pada Gambar 7.7

Gambar 7.7 Running program pada form 3

Laporan Praktikum Pemrograman Komputer 2023 VII-12


DAFTAR PUSTAKA
Tim Asisten Laboratorium Teknik Industri UPN V YK. (2023). Modul Praktikum
Pemrograman Komputer. Yogyakarta
Isa, Indra G.T. (2021). Buku Ajar Pemrograman Visual Dasar. Pekalongan: PT.
Nasya Expanding Management
Raharjo, Budi. (2016). Mudah Belajar VB.NET. Bandung: Informatika.

Anda mungkin juga menyukai