TUTORIAL
DAN ANALISIS PROGRAM KASIR SEDERHANA
Untuk membuat program kasir sederhana, maka listing
yang harus digunakan adalah sebagai berikut:
Form 1
Public Class Form1
Private Sub
Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button2.Click
Close()
End Sub
Keterangan:
Baris 1 untuk
menutup program
Private Sub
Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Form2.Show()
Me.Hide()
End Sub
Keterangan:
Baris 1 untuk
memunculkan Form 2
Baris 2 untuk
menyembunyikan Form 1
Me adalah nama
yang diberikan untuk Form 1
End Class
Form 2
Public Class Form2
Private Sub
ComboBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
ComboBox1.TextChanged
If ComboBox1.Text = ("Indonesian
2012/2014 Home Kit") Then
TextBox1.Text = ("489000")
If ComboBox1.Text = ("Indonesian
2012/2014 Away Kit") Then
TextBox1.Text = ("489000")
If ComboBox1.Text = ("Nike
Mercurial") Then TextBox1.Text = ("799000")
If ComboBox1.Text = ("Nike
CTR360") Then TextBox1.Text = ("799000")
If ComboBox1.Text = ("Nike
T90") Then TextBox1.Text = ("780000")
If ComboBox1.Text = ("Nike
Tiempo") Then TextBox1.Text = ("750000")
If ComboBox1.Text = ("Nike
Maxim HI-VIS Ball") Then
TextBox1.Text = ("150000")
End Sub
Keterangan:
Baris
1-9 adalah listing code dimana ketika
ketika memilih sebuah item pada
ComboBox1 maka akan secara otomatis nilai harga dari barang tersebut keluar
pada TextBox1
Private Sub
Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Dim Diskon As Double
Dim Total As Double
Dim Jumlah As Integer
Dim Harga As Integer
Harga
= Val(TextBox1.Text)
Jumlah = Val(TextBox4.Text)
Diskon = Val(TextBox3.Text)
If Jumlah > 6 Then
Diskon = (Harga * Jumlah * 50) / 100
TextBox3.Text = "50%"
ElseIf
Jumlah > 3 Then
Diskon = (Harga * Jumlah * 25) / 100
TextBox3.Text = "25%"
Else
Diskon = 0
TextBox3.Text = ""
End If
Total
= ((Harga * Jumlah) - Diskon)
TextBox2.Text = Total
End Sub
Keterangan:
Baris
1 menyatakan variabel nilai Diskon sebagai double
Baris
2 menyatakan variabel nilai Total sebagai double
Baris
3 menyatakan variabel nilai Jumlah sebagai integer
Baris
4 menyatakan variabel nilai Harga sebagai integer
Baris
5 menyatakan Harga pada TextBox1 memiliki nilai
Baris
6 menyatakan Jumlah pada TextBox1 memiliki nilai
Baris
7 menyatakan Diskon pada TextBox1 memiliki nilai
Baris
8-10 adalah listing code ketika
jumlah barang yang dimasukkan lebih dari 6 maka akan mendapatkan potongan harga
sebesar 50%
Baris
11-13 adalah listing code ketika
jumlah barang yang dimasukkan lebih dari 3 dan kurang dari 6 maka akan
mendapatkan potongan harga sebesar 25%
Baris
14-16 adalah listing code jika jumlah
item yang dibelanjakan kurang dari 3 maka tidak akan mendapatkan potongan harga
Baris
18-19 adalah listing code untuk
menemukan hasil total harga dari barang yang dibelanjakan.
Private Sub
Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button4.Click
Dim Dis As String = TextBox3.Text
Dim Tot As String = TextBox2.Text
Dim Jum As String = TextBox4.Text
Dim Har As String = TextBox1.Text
Dim Nb As String = ComboBox1.Text
DataGridView1.Rows.Add(Nb, Jum, Dis, Tot)
ComboBox1.Text = ""
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
PictureBox1.Hide()
PictureBox2.Hide()
PictureBox3.Hide()
PictureBox4.Hide()
PictureBox5.Hide()
PictureBox6.Hide()
PictureBox7.Hide()
End Sub
Keterangan:
Baris 1-18
adalah listing code untuk memasukkan
data hasil belanjaan kepada tabel belanjaan, sekaligus menghapus data yang
telah dimasukkan sebelumnya pada form pengisian
Private Sub
Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button3.Click
ComboBox1.Text = ""
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
DataGridView1.Rows.Clear()
PictureBox1.Hide()
PictureBox2.Hide()
PictureBox3.Hide()
PictureBox4.Hide()
PictureBox5.Hide()
PictureBox6.Hide()
PictureBox7.Hide()
End Sub
Private Sub
Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button5.Click
Dim TotalBelanja As Long
TotalBelanja = 0
For t As Integer = 0 To
DataGridView1.Rows.Count - 1
TotalBelanja = TotalBelanja + Val(DataGridView1.Rows(t).Cells(3).Value)
Next
TextBox5.Text = TotalBelanja
End Sub
Keterangan:
Baris
1-6 adalah listing code untuk
menghitung jumlah total keseluruhan dari barang-barang yang telah dibelanjakan.
Private Sub
Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button6.Click
If TextBox6.Text = ""
Then
MsgBox("Maaf, uang yang di input tidak
mencukupi!")
ElseIf TextBox5.Text < TextBox6.Text Then
TextBox7.Text = TextBox6.Text - TextBox5.Text
End If
End Sub
Private Sub
Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button2.Click
Me.Close()
End Sub
Keterangan
:
Baris
1-2 adalah listing code untuk
menyatakan bahwa uang yang dibayarkan tidak mencukupi dari subtotal yang
seharusnya dibayarakan.
Baris
3-4 adalah listing code untuk
menghitung jumlah kembalian yang harus diberikan jika jumlah yang harus
dibayarkan pada subtotal melebihi atau mencukupi yang seharusnya
Private Sub
Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button7.Click
If ComboBox1.Text = "Indonesian
2012/2014 Home Kit" Then
PictureBox1.Visible = True
PictureBox2.Visible = False
PictureBox3.Visible = False
PictureBox4.Visible = False
PictureBox5.Visible = False
PictureBox6.Visible = False
PictureBox7.Visible = False
ElseIf ComboBox1.Text = "Indonesian
2012/2014 Away Kit" Then
PictureBox1.Visible = False
PictureBox2.Visible = True
PictureBox3.Visible = False
PictureBox4.Visible = False
PictureBox5.Visible = False
PictureBox6.Visible = False
PictureBox7.Visible = False
ElseIf ComboBox1.Text = "Nike
Mercurial" Then
PictureBox1.Visible = False
PictureBox2.Visible = False
PictureBox3.Visible = True
PictureBox4.Visible = False
PictureBox5.Visible = False
PictureBox6.Visible = False
PictureBox7.Visible = False
ElseIf ComboBox1.Text = "Nike
CTR360" Then
PictureBox1.Visible = False
PictureBox2.Visible = False
PictureBox3.Visible = False
PictureBox4.Visible = True
PictureBox5.Visible = False
PictureBox6.Visible = False
PictureBox7.Visible = False
ElseIf ComboBox1.Text = "Nike
T90" Then
PictureBox1.Visible = False
PictureBox2.Visible = False
PictureBox3.Visible = False
PictureBox4.Visible = False
PictureBox5.Visible = True
PictureBox6.Visible = False
PictureBox7.Visible = False
ElseIf ComboBox1.Text = "Nike
Tiempo" Then
PictureBox1.Visible = False
PictureBox2.Visible = False
PictureBox3.Visible = False
PictureBox4.Visible = False
PictureBox5.Visible = False
PictureBox6.Visible = True
PictureBox7.Visible = False
ElseIf ComboBox1.Text = "Nike
Maxim HI-VIS Ball" Then
PictureBox1.Visible = False
PictureBox2.Visible = False
PictureBox3.Visible = False
PictureBox4.Visible = False
PictureBox5.Visible = False
PictureBox6.Visible = False
PictureBox7.Visible = True
End If
End Sub
Keterangan:
Baris 1-8 adalah listing code untuk memunculkan gambar
jika item yang dipilih adalah “Indonesian 2012/20124 Home Kit”
Baris 9-16
adalah listing code untuk memunculkan
gambar jika item yang dipilih adalah “Indonesian 2012/20124 Away Kit”
Baris 17-24
adalah listing code untuk memunculkan
gambar jika item yang dipilih adalah “Nike Mercurial”
Baris 25-32
adalah listing code untuk memunculkan
gambar jika item yang dipilih adalah “Nike CTR360”
Baris 33-40
adalah listing code untuk memunculkan
gambar jika item yang dipilih adalah “Nike T90”
Baris 41-48
adalah listing code untuk memunculkan
gambar jika item yang dipilih adalah “Nike Tiempo”
Baris 49-56
adalah listing code untuk memunculkan
gambar jika item yang dipilih adalah “Nike Maxim HI-VIS Ball”
End Class
Komponen
Toolbox Yang Digunakan:
Komponen
|
Properties
|
Keterangan
|
Form1
|
Nama
Text
|
Form
1
Home
Page
|
Button1
|
Name
Text
|
Button1
Enter
Application
|
Button2
|
Name
Text
|
Button2
Exit
|
Form2
|
Name
Text
|
Form2
Cashier
Application
|
Label1
|
Name
Text
|
Label1
Cashier
Application
|
Label2
|
Name
Text
|
Label2
Nama
Barang
|
Label3
|
Name
Text
|
Label3
Harga
|
Label4
|
Name
Text
|
Label4
Jumlah
|
Label5
|
Name
Text
|
Label5
Diskon
|
Label6
|
Name
Text
|
Label6
Total
|
ComboBox1
|
Name
Text
|
CoomboBox1
Indonesian 2012/2014
Home Kit
Indonesian 2012/2014
Away Kit
Nike Mercurial
Nike CTR360
Nike T90
Nike Tiempo
Nike Maxim HI-VIS
Ball
|
TextBox1
|
Name
Text
|
TextBox1
|
TextBox2
|
Name
Text
|
TextBox1
|
TextBox3
|
Name
Text
|
TextBox3
|
Button1
|
Name
Text
|
Button1
Total
|
Button2
|
Name
Text
|
Button2
Finish
|
Button3
|
Name
Text
|
Button3
Refresh
|
Button4
|
Name
Text
|
Button4
Add
To Chart
|
DataGridView1
|
Name
Text
|
DataGridView1
Nama
Barang
Jumlah
Diskon
Total
|
Button5
|
Name
Text
|
Button5
Sub
Total
|
TextBox6
|
Name
Text
|
TextBox6
|
Button6
|
Name
Text
|
Button6
Bayar
|
TextBox7
|
Name
Text
|
TextBox7
|
Label8
|
Name
Text
|
Label8
Kembalian
|
Button7
|
Name
Text
|
Button7
Preview
|
PictureBox1
|
Name
Image
|
PictureBox1
|
PictureBox2
|
Name
Image
|
PictureBox2
|
PictureBox3
|
Name
Image
|
PictureBox3
|
PictureBox4
|
Name
Image
|
PictureBox4
|
PictureBox5
|
Name
Image
|
PictureBox5
|
PictureBox6
|
Name
Image
|
PictureBox6
|
PictureBox7
|
Name
Image
|
PictureBox7
|
TUTORIAL DAN ANALISIS PROGRAM
MENGHITUNG AKAR PERSAMAAN KUADRAT
Untuk membuat program menghitung akar persamaan
kuadrat maka listing code yang harus
dimasukkan adalah sebagai berikut:
Public Class Form1
Dim a, b, c, D, X1, X2 As
Double
Private Sub
Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
a =
Val(TextBox1.Text)
b =
Val(TextBox2.Text)
c =
Val(TextBox3.Text)
D =
((b ^ 2) + -(4 * a * c))
X1 =
(((b) + Math.Sqrt(D)) / (2 * a))
X2 =
(((b) - Math.Sqrt(D)) / (2 * a))
Me.TextBox4.Text = X1
Me.TextBox5.Text = X2
End Sub
Keterangan
:
Baris
1-3 untuk menyatakan bahwa TextBox1, TextBox2, dan TextBox3 memiliki nilai
Baris
4 adalah rumus diskriminan (untuk mencari akar-akar persamaan kuadrat)
Baris
5-6 adalah listing code untuk mencari
hasil akar-akar dari persamaan kuadrat yang telah di-input kan
Baris
7 adalah listing code untuk
menuliskan hasil akar X1 dari persamaan pada TextBox4
Baris
8 adalah listing code untuk
menuliskan hasil akar X2 dari persamaan pada TextBox5
Private Sub
Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button2.Click
Me.Close()
End Sub
Keterangan:
Baris 1
berfungsi untuk menutup program
Me adalah nama
yang diberikan untuk Form1
Private Sub
Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button3.Click
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
End Sub
Keterangan:
Baris 1-5 adalah
listing code untuk menghapus data
yang telah di-inputkan dan telah dihasilkan
End Class
Komponen Toolbox
Yang Digunakan
Komponen
|
Properties
|
Kegunaan
|
Form1
|
Name
Text
|
Form1
Menghitung Akar
Persamaan Kuadrat
|
Label7
|
Name
Text
|
Label7
Menghitung Akar
Persamaan Kuadrat
|
TextBox1
|
Name
Text
|
TextBox1
|
TextBox2
|
Name
Text
|
TextBox2
|
TextBox3
|
Name
Text
|
TextBox3
|
Label1
|
Name
Text
|
Label1
X ^ 2+
|
Label2
|
Name
Text
|
Label2
X +
|
Button1
|
Name
Text
|
Button1
Calculate!
|
Label3
|
Name
Text
|
Label3
X1 =
|
Label4
|
Name
Text
|
Label4
X2 =
|
Label5
|
Name
Text
|
Label5
|
Label6
|
Name
Text
|
Label6
|
Button3
|
Name
Text
|
Button3
Reset
|
Button2
|
Name
Text
|
Button2
Close
|
TUTORIAL
DAN ANALISIS PROGRAM KALKULATOR SCIENTIFIC
Untuk membuat program kalkulator scientific, maka
listing yang harus digunakan adalah sebagai berikut:
Form 1
Dim Angka, Hasil As Double
Dim proses As String
Dim a, b, i As Integer
Dim tombolON As Boolean
Const pi As Double = 3.14159265358979
Private Sub
Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
tombolON = False
Me.ForeColor = Color.GhostWhite
Button23.ForeColor = Color.Black
Button29.ForeColor = Color.Black
End Sub
Private Sub
Button29_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button29.Click
tombolON = True
Me.ForeColor = Color.Black
End Sub
Keterangan:
Baris 1 untuk
menentukan tipe data yang akan dipakai pada proses selanjutnya
Baris 7
(paragraf 2) menunjukan bahwa program belum aktif
Baris 9 untuk
mengaktifkan program
Private Sub Button1_Click(ByVal sender As
System.Object, ByVal
e As System.EventArgs)
Handles Button1.Click
If tombolON = False Then
Exit Sub
End If
If Label1.Text = "0"
Then
Label1.Text = "1"
TextBox2.Text = "1"
Else
Label1.Text = Label1.Text & "1"
TextBox2.Text = TextBox2.Text & "1"
End If
End Sub
Private Sub
Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button2.Click
If tombolON = False Then
Exit Sub
End If
If Label1.Text = "0"
Then
Label1.Text = "2"
TextBox2.Text = "2"
Else
Label1.Text = Label1.Text & "2"
TextBox2.Text = TextBox2.Text & "2"
End If
End Sub
Private Sub
Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button3.Click
If tombolON = False Then
Exit Sub
End If
If Label1.Text = "0"
Then
Label1.Text = "3"
TextBox2.Text = "3"
Else
Label1.Text = Label1.Text & "3"
TextBox2.Text = TextBox2.Text & "3"
End If
End Sub
Private Sub
Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button4.Click
If tombolON = False Then
Exit Sub
End If
If Label1.Text = "0"
Then
Label1.Text = "4"
TextBox2.Text = "4"
Else
Label1.Text = Label1.Text & "4"
TextBox2.Text = TextBox2.Text & "4"
End If
End Sub
Private Sub
Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button5.Click
If tombolON = False Then
Exit Sub
End If
If Label1.Text = "0"
Then
Label1.Text = "5"
TextBox2.Text = "5"
Else
Label1.Text = Label1.Text & "5"
TextBox2.Text = TextBox2.Text & "5"
End If
End Sub
Private Sub
Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button6.Click
If tombolON = False Then
Exit Sub
End If
If Label1.Text = "0"
Then
Label1.Text = "6"
TextBox2.Text = "6"
Else
Label1.Text = Label1.Text & "6"
TextBox2.Text = TextBox2.Text & "6"
End If
End Sub
Private Sub
Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button7.Click
If tombolON = False Then
Exit Sub
End If
If Label1.Text = "0"
Then
Label1.Text = "7"
TextBox2.Text = "7"
Else
Label1.Text = Label1.Text & "7"
TextBox2.Text = TextBox2.Text & "7"
End If
End Sub
Private Sub
Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button8.Click
If tombolON = False Then
Exit Sub
End If
If Label1.Text = "0"
Then
Label1.Text = "8"
TextBox2.Text = "8"
Else
Label1.Text = Label1.Text & "8"
TextBox2.Text = TextBox2.Text & "8"
End If
End Sub
Private Sub
Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button9.Click
If tombolON = False Then
Exit Sub
End If
If Label1.Text = "0"
Then
Label1.Text = "9"
TextBox2.Text = "9"
Else
Label1.Text = Label1.Text & "9"
TextBox2.Text = TextBox2.Text & "9"
End If
End Sub
Private Sub
Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button10.Click
If tombolON = False Then
Exit Sub
End If
If Label1.Text = "0"
Then
Label1.Text = "0"
TextBox2.Text = "0"
Else
Label1.Text = Label1.Text & "0"
TextBox2.Text = TextBox2.Text & "0"
End If
End Sub
Private Sub
Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button12.Click
If tombolON = False Then
Exit Sub
End If
Label1.Text = Label1.Text & "."
TextBox2.Text = TextBox2.Text & "."
End Sub
Private Sub
Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button13.Click
If tombolON = False Then
Exit Sub
End If
If Label1.Text = "0"
Then
Label1.Text = "00"
TextBox2.Text = "00"
Else
Label1.Text = Label1.Text & "00"
TextBox2.Text = TextBox2.Text & "00"
End If
End Sub
Keterangan :
Listing di atas
merupakan kode untuk memunculkan angka yang akan dipilih, mulai dari angka 1
hingga 00
Private Sub
Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button15.Click
TextBox2.Text = TextBox2.Text & "+"
If proses <> ""
Then
Select Case proses
Case "+"
Call Tambah()
Case "-"
Call kurang()
Case "x"
Call kali()
Case "/"
Call bagi()
Case "^"
Call pangkat()
Case "log"
Call Log()
Case "^1/2″"
Call akar()
Case "N!"
Call faktorial()
Case "%"
Call persen()
Case "Sin"
Call Sin()
Case "Cos"
Call Cos()
Case "Tan"
Call Tan()
End Select
Else
Call Tambah()
End If
proses = "+"
Label1.Text = ""
End Sub
Private Sub Tambah()
If Angka = "0"
Then
Angka = Val(Label1.Text)
Else
Angka = Angka + Val(Label1.Text)
End If
proses = "+"
Label1.Text = ""
End Sub
Keterangan :
Listing di atas adalah
untuk fungsi penambahan pada program
Private Sub
Button17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button17.Click
TextBox2.Text = TextBox2.Text & "-"
If proses <> ""
Then
Select Case proses
Case "+"
Call Tambah()
Case "-"
Call kurang()
Case "x"
Call kali()
Case "/"
Call bagi()
Case "^"
Call pangkat()
Case "log"
Call Log()
Case "^0.5"
Call akar()
Case "N!"
Call faktorial()
Case "%"
Call persen()
Case "Sin"
Call Sin()
Case "Cos"
Call Cos()
Case "Tan"
Call Tan()
End Select
Else
Call kurang()
End If
proses = "-"
Label1.Text = ""
End Sub
Private Sub kurang()
If Angka = "0"
Then
Angka = Val(Label1.Text)
Else
Angka = Angka - Val(Label1.Text)
End If
proses = "-"
Label1.Text = ""
End Sub
Keterangan :
Listing di atas untuk
fungsi pengurangan pada program
Private Sub
Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button16.Click
TextBox2.Text = TextBox2.Text & "/"
If proses <> ""
Then
Select Case proses
Case "+"
Call Tambah()
Case "-"
Call kurang()
Case "x"
Call kali()
Case "/"
Call bagi()
Case "^"
Call pangkat()
Case "log"
Call Log()
Case "^0.5"
Call akar()
Case "N!"
Call faktorial()
Case "%"
Call persen()
Case "Sin"
Call Sin()
Case "Cos"
Call Cos()
Case "Tan"
Call Tan()
End Select
Else
Call bagi()
End If
proses = "/"
Label1.Text = ""
End Sub
Private Sub bagi()
If Angka = "0"
Then
Angka = Val(Label1.Text)
Else
Angka = Angka / Val(Label1.Text)
End If
proses = "/"
Label1.Text = ""
End Sub
Keterangan :
Listing diatas untuk
fungsi pembagi
Private Sub
Button18_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button18.Click
TextBox2.Text = TextBox2.Text & "^"
If proses <> ""
Then
Select Case proses
Case "+"
Call Tambah()
Case "-"
Call kurang()
Case "x"
Call kali()
Case "/"
Call bagi()
Case "^"
Call pangkat()
Case "log"
Call Log()
Case "^0.5"
Call akar()
Case "N!"
Call faktorial()
Case "%"
Call persen()
Case "Sin"
Call Sin()
Case "Cos"
Call
Cos()
Case "Tan"
Call Tan()
End Select
Else
Call pangkat()
End If
proses = "^"
Label1.Text = ""
End Sub
Private Sub pangkat()
If Angka = "0"
Then
Angka = Val(Label1.Text)
Else
Angka = Angka ^ Val(Label1.Text)
End If
proses = "^"
Label1.Text = ""
End Sub
Keterangan :
Listing diatas untuk
fungsi pangkat
Private Sub
Button19_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button19.Click
TextBox2.Text = TextBox2.Text & "x"
If proses <> ""
Then
Select Case proses
Case "+"
Call Tambah()
Case "-"
Call kurang()
Case "x"
Call kali()
Case "/"
Call bagi()
Case "^"
Call pangkat()
Case "log"
Call Log()
Case "^0.5"
Call akar()
Case "N!"
Call faktorial()
Case "%"
Call persen()
Case "Sin"
Call
Sin()
Case "Cos"
Call Cos()
Case "Tan"
Call Tan()
End Select
Else
Call kali()
End If
proses = "x"
Label1.Text = ""
End Sub
Private Sub kali()
If Angka = "0"
Then
Angka = Val(Label1.Text)
Else
Angka = Angka * Val(Label1.Text)
End If
proses = "x"
Label1.Text = ""
End Sub
Keterangan :
Listing di atas untuk
fungsi perkalian
Private Sub
Button20_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button20.Click
TextBox2.Text = "log" &
TextBox2.Text
If proses <> ""
Then
Select Case proses
Case "+"
Call Tambah()
Case "-"
Call kurang()
Case "x"
Call kali()
Case "/"
Call bagi()
Case "^"
Call pangkat()
Case "log"
Call Log()
Case "^0.5"
Call akar()
Case "N!"
Call faktorial()
Case "%"
Call persen()
Case "Sin"
Call Sin()
Case "Cos"
Call Cos()
Case "Tan"
Call Tan()
End Select
Else
Call Log()
End If
proses = "log10"
TextBox1.Text = ""
End Sub
Private Sub Log()
proses = "log10"
TextBox1.Text = ""
TextBox2.Text = "log" &
Label1.Text
End Sub
Keterangan:
Listng diatas untuk fingsi
logaritma
Private Sub
Button28_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button28.Click
TextBox2.Text = "√" &
Label1.Text
If proses <> ""
Then
Select Case proses
Case "+"
Call Tambah()
Case "-"
Call kurang()
Case "x"
Call kali()
Case "/"
Call bagi()
Case "^"
Call pangkat()
Case "log"
Call Log()
Case "^0.5"
Call akar()
Case "N!"
Call faktorial()
Case "%"
Call persen()
Case "Sin"
Call Sin()
Case "Cos"
Call Cos()
Case "Tan"
Call Tan()
End Select
Else
Call akar()
End If
proses = "√"
TextBox1.Text = ""
End Sub
Private Sub akar()
proses = "√"
TextBox1.Text = ""
TextBox2.Text = "√" &
Label1.Text
End Sub
Keterangan :
Listing di atas untuk
fungsi akar
Private Sub
Button27_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button27.Click
TextBox2.Text = TextBox2.Text & "!"
If proses <> ""
Then
Select Case proses
Case "+"
Call Tambah()
Case "-"
Call kurang()
Case "x"
Call kali()
Case "/"
Call bagi()
Case "^"
Call pangkat()
Case "log"
Call Log()
Case "^0.5"
Call akar()
Case "N!"
Call faktorial()
Case "%"
Call persen()
Case "Sin"
Call Sin()
Case "Cos"
Call Cos()
Case "Tan"
Call Tan()
End Select
Else
Call faktorial()
End If
TextBox1.Text = ""
proses = "N!"
End Sub
Private Sub
faktorial()
a = 1
For Me.i = 1 To Val(Label1.Text)
a
= a * i
Next
TextBox2.Text = Label1.Text & "!"
End Sub
Keterangan :
Lisitng di atas untuk
fungsi faktorial
Private Sub
Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button11.Click
TextBox2.Text = TextBox2.Text & "%"
If proses <> ""
Then
Select Case proses
Case "+"
Call Tambah()
Case "-"
Call kurang()
Case "x"
Call kali()
Case "/"
Call bagi()
Case "^"
Call pangkat()
Case "log"
Call Log()
Case "^0.5"
Call akar()
Case "N!"
Call faktorial()
Case "%"
Call persen()
Case "Sin"
Call Sin()
Case "Cos"
Call Cos()
Case "Tan"
Call Tan()
End Select
Else
Call persen()
End If
proses = "%"
Label1.Text = ""
End Sub
Private Sub persen()
If Angka = 0 Then
Angka = Val(Label1.Text)
Else
Angka = Angka / 100
End If
proses = "%"
TextBox1.Text = ""
End Sub
Keterangan :
Listing di atas untuk
fungsi persen
Private Sub
Button24_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button24.Click
TextBox2.Text = "Sin" &
TextBox2.Text
If proses <> ""
Then
Select Case proses
Case "+"
Call Tambah()
Case "-"
Call kurang()
Case "x"
Call kali()
Case "/"
Call bagi()
Case "^"
Call pangkat()
Case "log"
Call Log()
Case "^0.5"
Call akar()
Case "N!"
Call faktorial()
Case "%"
Call persen()
Case "Sin"
Call Sin()
Case "Cos"
Call Cos()
Case "Tan"
Call Tan()
End Select
Else
Call Sin()
End If
proses = "Sin"
TextBox1.Text = ""
End Sub
Private Sub Sin()
proses = "Sin"
TextBox1.Text = ""
TextBox2.Text = "Sin" &
Label1.Text
End Sub
Private Sub
Button25_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button25.Click
TextBox2.Text = "Cos" &
TextBox2.Text
If proses <> ""
Then
Select Case proses
Case "+"
Call Tambah()
Case "-"
Call kurang()
Case "x"
Call kali()
Case "/"
Call bagi()
Case "^"
Call pangkat()
Case "log"
Call Log()
Case "^0.5"
Call akar()
Case "N!"
Call faktorial()
Case "%"
Call persen()
Case
"Sin"
Call Sin()
Case "Cos"
Call Cos()
Case "Tan"
Call Tan()
End Select
Else
Call Cos()
End If
proses = "Cos"
TextBox1.Text = ""
End Sub
Private Sub Cos()
proses = "Cos"
TextBox1.Text = ""
TextBox2.Text = "Cos" &
Label1.Text
End Sub
Private Sub
Button26_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button26.Click
TextBox2.Text = "Tan" &
TextBox2.Text
If proses <> ""
Then
Select Case proses
Case "+"
Call Tambah()
Case "-"
Call
kurang()
Case "x"
Call kali()
Case "/"
Call bagi()
Case "^"
Call pangkat()
Case "log"
Call Log()
Case "^0.5"
Call akar()
Case "N!"
Call faktorial()
Case "%"
Call persen()
Case "Sin"
Call Sin()
Case "Cos"
Call Cos()
Case "Tan"
Call Tan()
End Select
Else
Call Tan()
End If
proses = "Tan"
TextBox1.Text = ""
End Sub
Private Sub Tan()
proses = "Tan"
TextBox1.Text = ""
TextBox2.Text = "Tan" &
Label1.Text
End Sub
Keterangan:
Listing diatas untuk
fungsi sin, cos, tan
Private Sub
Button22_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button22.Click
TextBox1.Text = "0"
TextBox2.Text = ""
Label1.Text = ""
Angka
= 0
Hasil
= 0
proses = ""
End Sub
Keterangan :
listing diatas untuk
fungsi clear, manghapus (merefresh data)
Private Sub
Button21_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button21.Click
If TextBox2.Text.Length <> 0 Then
TextBox2.Text = TextBox2.Text.Remove(TextBox2.Text.Length - 1, 1)
TextBox1.Text = TextBox1.Text.Remove(TextBox1.Text.Length - 1, 1)
End If
End Sub
Keterangan :
Listing tersebut untuk
fungsi delete
Private Sub
Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button14.Click
If proses = "+"
Then
Hasil = Angka + Val(Label1.Text)
TextBox1.Text = Hasil
Label1.Text = Hasil
ElseIf proses = "-"
Then
Hasil = Angka - Val(Label1.Text)
TextBox1.Text = Hasil
Label1.Text = Hasil
ElseIf proses = "x"
Then
Hasil = Angka * Val(Label1.Text)
TextBox1.Text = Hasil
Label1.Text = Hasil
ElseIf proses = "/"
Then
Hasil = Angka / Val(Label1.Text)
TextBox1.Text = Hasil
Label1.Text = Hasil
ElseIf proses = "^"
Then
Hasil = Angka ^ Val(Label1.Text)
TextBox1.Text = Hasil
Label1.Text = Hasil
ElseIf
proses = "%" Then
Hasil = Angka / 100
TextBox1.Text = Hasil
Label1.Text = Hasil
ElseIf proses = "√"
Then
Hasil = Val(Label1.Text) ^ 0.5
TextBox1.Text = Hasil
Label1.Text = Hasil
ElseIf proses = "Cos"
Then
Hasil = Math.Cos(Val(Label1.Text) *
(pi / 180))
TextBox1.Text = Hasil
Label1.Text = Hasil
ElseIf proses = "Sin"
Then
Hasil = Math.Sin(Val(Label1.Text) *
(pi / 180))
TextBox1.Text = Hasil
Label1.Text = Hasil
ElseIf proses = "Tan"
Then
Hasil = Math.Tan(Val(Label1.Text) *
(pi / 180))
TextBox1.Text = Hasil
Label1.Text = Hasil
ElseIf proses = "N!"
Then
TextBox1.Text = a
Label1.Text = a
ElseIf proses = "log10"
Then
Hasil = Math.Log10(Val(Label1.Text))
TextBox1.Text = Hasil
Label1.Text
= Hasil
End If
proses = ""
Angka
= 0
End Sub
Keterangan:
Listing tersebut
untuk menghitung hasil dari data program
yang telahh diolah
Private Sub
Button23_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button23.Click
tombolON = False
Me.ForeColor = Color.GhostWhite
Button23.ForeColor = Color.Black
Button29.ForeColor = Color.Black
TextBox1.Text = "0"
TextBox2.Text = ""
Label1.Text = ""
Angka
= 0
Hasil
= 0
proses = ""
End Sub
Keterangan
:
Listing
diatas untuk menonaktifkan semua tombol kecuali on dan off
Private Sub
Button30_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button30.Click
If MsgBox("exit")
Then
Close()
End If
End Sub
Keterangan :
Listing diatas untuk
keluar dari program
Komponen
Toolbox Yang Digunakan:
Komponen
|
Properties
|
Keterangan
|
Form1
|
Nama
Text
|
Form
1
Kalkulatorscientificjadisip
|
Button1
|
Name
Text
|
Button1
1
|
Button2
|
Name
Text
|
Button2
2
|
Button3
|
Name
Text
|
Button3
3
|
Button4
|
Name
Text
|
Button4
4
|
Button5
|
Name
Text
|
Button5
5
|
Button6
|
Name
Text
|
Button6
6
|
Button7
|
Name
Text
|
Button7
7
|
Button8
|
Name
Text
|
Button8
8
|
Button9
|
Name
Text
|
Button9
9
|
Button10
|
Name
Text
|
Button10
0
|
Button11
|
Name
Text
|
Button11
%
|
Button12
|
Name
Text
|
Button12
.
|
Button13
|
Name
Text
|
Button13
00
|
Button14
|
Name
Text
|
Button14
=
|
Button15
|
Name
Text
|
Button15
+
|
Button16
|
Name
Text
|
Button16
/
|
Button17
|
Name
Text
|
Button17
-
|
Button18
|
Name
Text
|
Button18
^
|
Button19
|
Name
Text
|
Button19
X
|
Button20
|
Name
Text
|
Button20
Log
|
Button21
|
Name
Text
|
Button21
Del
|
Button22
|
Name
Text
|
Button22
Clear
|
Button23
|
Name
Text
|
Button23
Off
|
Button24
|
Name
Text
|
Button24
Sin
|
Button25
|
Name
Text
|
Button25
Cos
|
Button26
|
Name
Text
|
Button26
Tan
|
Button27
|
Name
Text
|
Button27
!
|
Button28
|
Name
Text
|
Button28
|
Button29
|
Name
Text
|
Button29
|
Button30
|
Name
Text
|
Button30
Exit
|
Label1
|
Name
Text
|
Label1
|
Label2
|
Name
Text
|
Label2
43’sSMART
CALCULATOR
|
Textbox1
|
Name
Text
|
Textbox1
|
Textbox2
|
Name
Text
|
Textbox2
|
TUTORIAL DAN
ANALISIS PROGRAM BANGUN 2 DAN 3 DIMENSI
Untuk membuat program bangun 2 dan 3
dimensi maka listing code yang harus
dimasukkan adalah sebagai berikut:
Form1
Public Class Form1
Private Sub
Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
End Sub
Private Sub
Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub
ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
ComboBox1.SelectedIndexChanged
(1) If
ComboBox1.Text = "Persegi" Then
Form2.Show()
Me.Hide()
End If
(2) If
ComboBox1.Text = "Persegi Panjang"
Then
Form3.Show()
Me.Hide()
End If
(3) If
ComboBox1.Text = "Lingkaran" Then
Form4.Show()
Me.Hide()
End If
End Sub
Private Sub
ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
ComboBox2.SelectedIndexChanged
(3) If ComboBox2.Text = "Balok"
Then
Form5.Show()
Me.Hide()
End If
(4) If ComboBox2.Text = "Kubus"
Then
Form6.Show()
Me.Hide()
End If
End Sub
Private Sub
Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
Me.Close()
End Sub
Private Sub
Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Label1.Click
End Sub
End Class
Keterangan :
Baris 1 menunjukan
gambar 2D yaitu “persegi” maka berpindah ke form 2
Baris 2 menunjukan
gambar 2D yaitu “persegi panjang"maka pindah ke form 3
Baris 3 menunjukan
gambar 2D yaitu “lingkaran” maka pindah ke form 4
Baris 4 menunjukan
gambar 3D yaitu “balok” maka pindah ke form 5
Baris 5 menunjukan
gambar 3D yaitu “kubus” maka pindah ke form 6
Form2
Public Class Form2
(1) Dim sisipersegi
As Integer
Dim Kelilingpersegi As
Integer
Dim Luaspersegi As Integer
Private Sub
Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Label1.Click
End Sub
Private Sub
Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
(2) Form1.Show()
Me.Hide()
End Sub
Private Sub
TextBox1_KeyPress(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
Dim Num As Boolean = Char.IsDigit(e.KeyChar)
If (Not Num) Then e.Handled = True
End Sub
Private Sub
TextBox3_keypress(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles TextBox3.KeyPress
(3) Dim Num As Boolean = Char.IsDigit(e.keychar)
If (Not Num) Then e.Handled = True
End Sub
Private Sub
TextBox2_KeyPress(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress
Dim Num As Boolean = Char.IsDigit(e.keychar)
If (Not Num) Then e.Handled = True
End Sub
Private Sub
Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button2.Click
(4)
sisipersegi = Val(TextBox1.Text)
Kelilingpersegi = Val(TextBox3.Text)
Luaspersegi = Val(TextBox2.Text)
Luaspersegi = sisipersegi ^ 2
TextBox2.Text = Luaspersegi
Kelilingpersegi = sisipersegi * 4
TextBox3.Text = Kelilingpersegi
PictureBox1.Visible = True
PictureBox1.Height = sisipersegi * 9
PictureBox1.Width = sisipersegi * 9
End Sub
Private Sub
PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub
Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
End Sub
Private Sub
Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button3.Click
(5)
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
PictureBox1.Visible = "false"
End Sub
End Class
Keterangan
:
Baris
1 menunjukan bahwa sisipersegi, kelilingpersegi, dan luaspersegi adalah
bilangan bulat
Baris
2 menunjukan bahwa jika button ini di tekan akan berpindah ke form 1 dan
menutup form sebelumnya
Baris
3 menunjukan agar textboxnya ini Cuma bisa diisi angka saja
Baris
4 rumus dan skala yng di berikan pada gambar
Baris
5 menunjukan agar ketika button ini di klik akan clear semua textbox dan
menghilangkan gambar
Form3
Public Class Form3
(1) Dim
Panjangpersegipanjang As Integer
Dim Lebarpersegipanjang As
Integer
Dim Luaspersegipanjang As
Integer
Dim kelilingpersegipanjang As
Integer
Private Sub
TextBox1_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
(2) Dim Num As Boolean = Char.IsDigit(e.KeyChar)
If (Not Num) Then e.Handled = True
End Sub
Private Sub
Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
End Sub
Private Sub
TextBox4_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles TextBox4.KeyPress
Dim Num As Boolean = Char.IsDigit(e.KeyChar)
If (Not Num) Then e.Handled = True
End Sub
Private Sub
TextBox2_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress
Dim Num As Boolean = Char.IsDigit(e.KeyChar)
If (Not Num) Then e.Handled = True
End Sub
Private Sub
TextBox3_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles TextBox3.KeyPress
Dim Num As Boolean = Char.IsDigit(e.KeyChar)
If (Not Num) Then e.Handled = True
End Sub
Private Sub
Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button2.Click
(3)
Panjangpersegipanjang = Val(TextBox1.Text)
Lebarpersegipanjang = Val(TextBox2.Text)
kelilingpersegipanjang = Val(TextBox4.Text)
Luaspersegipanjang = Val(TextBox3.Text)
Luaspersegipanjang = Panjangpersegipanjang * Lebarpersegipanjang
TextBox3.Text = Luaspersegipanjang
kelilingpersegipanjang = 2 * Panjangpersegipanjang + Lebarpersegipanjang
* 2
TextBox4.Text = kelilingpersegipanjang
PictureBox1.Visible = True
PictureBox1.Height = Panjangpersegipanjang * 9
PictureBox1.Width = Lebarpersegipanjang * 9
End Sub
Private Sub
TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
TextBox1.TextChanged
End Sub
Private Sub
Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
(4) Form1.Show()
Me.Hide()
End Sub
Private Sub
Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button3.Click
(5)
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
PictureBox1.Visible = "false"
End Sub
End Class
Keterangan :
Baris 1
menunjukan bahwa persegipanjang, lebarpersegipanjang, luaspersegipanjang, dan
kelilingnya adalah bilangan bulat
Baris
2 menunjukan agar textboxnya ini Cuma bisa diisi angka saja
Baris
3 menunjukan rumus kelilingpersegi, luaspersegi, dan skala pada gambar
baris
4 menunjukan bahwa jika button ini di
tekan akan berpindah ke form 1 dan menutup form sebelumnya
Baris
5 menunjukan agar ketika button ini di klik akan clear semua textbox dan
menghilangkan gambar
Form4
Public Class Form4
(1) Dim
Jarilingkaran As Integer
Dim luaslingkaran As Integer
Private Sub
Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
(2) Form1.Show()
Me.Hide()
End Sub
Private Sub
TextBox1_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
Dim Num As Boolean = Char.IsDigit(e.KeyChar)
If (Not Num) Then e.Handled = True
End Sub
Private Sub
TextBox3_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles TextBox3.KeyPress
(3) Dim Num As Boolean = Char.IsDigit(e.KeyChar)
If (Not Num) Then e.Handled = True
End Sub
Private Sub
Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button2.Click
(4)
Jarilingkaran = Val(TextBox1.Text)
luaslingkaran = Val(TextBox3.Text)
luaslingkaran = Jarilingkaran ^ 2 * 22 / 7
TextBox3.Text = luaslingkaran
PictureBox1.Visible = True
PictureBox1.Width = TextBox1.Text * 9
PictureBox1.Height = TextBox1.Text * 9
End Sub
Private Sub
Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Label1.Click
End Sub
Private Sub
PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
PictureBox1.Click
End Sub
Private Sub
Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button3.Click
(5)
TextBox1.Text = ""
TextBox3.Text = ""
PictureBox1.Visible = "false"
End Sub
End Class
Keterangan :
Baris 1 menunjukan
bahwa jarilingkaran dan luaslingkaran adalah bilangan bulat
Baris 2 menunjukan
bahwa jika button ini di tekan akan berpindah ke form 1 dan menutup form
sebelumnya
Baris 3 menunjukan agar
textboxnya ini hanya bisa diisi angka saja
Baris 4 menunjukan rumus
untuk mencari luas lingkaran dan skala pada gambar
Baris 5 menunjukan agar
ketika button ini di klik akan clear semua textbox dan menghilangkan gambar
Form5
Public Class Form5
(1) Dim
panjangbalok As Integer
Dim lebarbalok As Integer
Dim tinggibalok As Integer
Dim volumebalok As Integer
Private Sub
TextBox1_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
Dim Num As Boolean = Char.IsDigit(e.KeyChar)
If (Not Num) Then e.Handled = True
End Sub
Private Sub
Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
(2) Form1.Show()
Me.Hide()
End Sub
Private Sub
Label5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Label5.Click
End Sub
Private Sub
Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button2.Click
(3)
panjangbalok = Val(TextBox1.Text)
lebarbalok = Val(TextBox4.Text)
tinggibalok = Val(TextBox5.Text)
volumebalok = Val(TextBox2.Text)
volumebalok = panjangbalok * lebarbalok * tinggibalok
TextBox2.Text = volumebalok
PictureBox1.Visible = True
PictureBox1.Width = panjangbalok * 9
PictureBox1.Height = tinggibalok * 9
End Sub
Private Sub
TextBox5_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles TextBox5.KeyPress
(4) Dim Num As Boolean = Char.IsDigit(e.KeyChar)
If (Not Num) Then e.Handled = True
End Sub
Private Sub
TextBox4_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles TextBox4.KeyPress
Dim Num As Boolean = Char.IsDigit(e.KeyChar)
If (Not Num) Then e.Handled = True
End Sub
Private Sub
TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
TextBox1.TextChanged
End Sub
Private Sub
Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button3.Click
(5)
TextBox1.Text = ""
TextBox2.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
PictureBox1.Visible = "false"
End Sub
End Class
Keterangan
:
Baris
1 menunjukan bahwa panjangbalok, lebarbalok, tinggibalok, dan volumebalok
adalah bilangan bulat
Baris
2 menunjukan bahwa jika button ini di tekan akan berpindah ke form 1 dan
menutup form sebelumnya
Baris
3 rumus untuk mencari volumebalok dan skala pada gambar balok tersebut
Baris
4 menunjukan agar textboxnya ini Cuma bisa diisi angka saja
Baris
5 menunjukan agar ketika button ini di klik akan clear semua textbox dan
menghilangkan gambar
Form6
Public Class Form6
(1) Dim rusukkubus As Integer
Dim volumekubus As Integer
Private Sub
Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
(2) Form1.Show()
Me.Hide()
End Sub
Private Sub
TextBox1_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
(3) Dim Num As Boolean = Char.IsDigit(e.KeyChar)
If (Not Num) Then e.Handled = True
End Sub
Private Sub
TextBox2_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress
Dim Num As Boolean = Char.IsDigit(e.KeyChar)
If (Not Num) Then e.Handled = True
End Sub
Private Sub
Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button2.Click
(4)
rusukkubus = Val(TextBox1.Text)
volumekubus = Val(TextBox2.Text)
volumekubus = rusukkubus ^ 3
TextBox2.Text = volumekubus
PictureBox1.Visible = True
PictureBox1.Width = rusukkubus * 9
PictureBox1.Height = rusukkubus * 9
End Sub
Private Sub
Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button3.Click
(5)
TextBox1.Text = ""
TextBox2.Text = ""
PictureBox1.Visible = "false"
End Sub
Private Sub
Form6_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
End Sub
End Class
Keterangan
:
Baris
1 menunjukan bahwa rusukkubus dan volumekubus adalah bilangan bulat
Baris
2 menunjukan bahwa jika button ini di tekan akan berpindah ke form 1 dan
menutup form sebelumnya
Baris
3 menunjukan agar textboxnya ini hanya bisa diisi angka saja
Baris
4 rumus untuk mencari volume kubus dan skala pada gambar kubus tersebut
Baris
5 menunjukan agar ketika button ini di klik akan clear semua textbox dan
menghilangkan gambar
Tutorial Dan Analisis Listing Program Modul 2 bisa didownload disini :
http://www.4shared.com/office/I83hrK_w/Tutorial_Dan_Analisis_Program_.html
No comments:
Post a Comment