Judul Program : Geometrical Totalizer
Tujuan Program :
Ø Untuk menghitung luas bangun dan
keliling 2 dimensi seperti kotak, lingkaran dan segitiga
Ø Untuk menghitung luas bangun 3 dimensi
seperti balok dan kubus
Ø Mempermudah pekerjaan orang dalam
menghitung bentuk bentuk tersebut
Sasaran
Program : Program ini dapat digunakan oleh seluruh pihak, baik untuk anak-anak
maupun orang dewasa.
Deskripsi
Program :
1.
Form1
Form 1 dapat digunakan untuk menginput bentuk bangun 2 dimensi yang
kemudian akan muncul apabila kita memilih salah satu dari pilihan combo box
yang ditawarkan
2.
Form2
Form 2 dapat digunakan untuk menginput bentuk bangun 3 dimensi yang
kemudian akan muncul apabila kita memilih salah satu dari pilihan combo box
yang ditawarkan

3.
Form3
Form 3 muncul jika kita mengklik tombol exit. Form ini bertujuan untuk
meyakinkan user kembali apakah user benar-benar ingin keluar dari aplikasi.
TUTORIAL PROGRAM
Form 1
1.
Buatlah
new projects dengan jenis windows form application
2.
Buatlah
Label1 yang bertuliskan Geometrical Totalizer sebagai judul
3.
Buatlah
ComboBox dengan 3 pilihan (untuk 2D) yaitu rectangle, triangle dan circle
4.
Buatlah
form untuk rectangle seperti ini

5.
Buatlah
form untuk circle seperti ini

6.
Buatlah
Form untuk triangle seperti ini

7.
Lalu
buatlah button-button untuk pindah ke form 3D, untuk reset dan untuk exit
Komponen
Toolbox
Komponen
|
Properties
|
Keterangan
|
Form1
|
Name
Text
|
Form1
GeometricalTotalizer
|
Label 1
|
Name
Text
|
Label1
Height
|
Label 2
|
Name
Text
|
Label2
Width
|
Label 3
|
Name
Text
|
Label3
Geometrical Totalizer
|
Label 4
|
Name
Text
|
Label4
Pixels
|
Label 5
|
Name
Text
|
Label5
Pixels
|
Label 6
|
Name
Text
|
Label6
Total Area
|
Label 7
|
Name
Text
|
Label7
Total Circumference
|
Label 8
|
Name
Text
|
Label8
Radius
|
Label 9
|
Name
Text
|
Label9
Pixels
|
Label 10
|
Name
Text
|
Label10
Total Area
|
Label 11
|
Name
Text
|
Label11
Total Circumference
|
Label 12
|
Name
Text
|
Label12
Base
|
Label 13
|
Name
Text
|
Label13
Height
|
Label 14
|
Name
Text
|
Label14
Pixels
|
Label 15
|
Name
Text
|
Label15
Pixels
|
Label 16
|
Name
Text
|
Label16
Total Area
|
Label17
|
Name
Text
|
Label17
Total Circumference
|
Button 1
|
Name
Text
|
Button1
Generate
|
Button 2
|
Name
Text
|
Button2
Generate
|
Button 3
|
Name
Text
|
Button3
Generate
|
Button 4
|
Name
Text
|
Button4
Three Dimensions
|
Button 5
|
Name
Text
|
Button5
Exit
|
Button 6
|
Name
Text
|
Button6
Reset
|
ComboBox 1
|
Name
Text
|
ComboBox1
<Select Two
Dimensions Shape>
|
TextBox1
|
Name
Text
|
TextBox1
|
TextBox2
|
Name
Text
|
TextBox2
|
TextBox3
|
Name
Text
|
TextBox3
|
TextBox4
|
Name
Text
|
TextBox4
|
TextBox5
|
Name
Text
|
TextBox5
|
TextBox6
|
Name
Text
|
TextBox6
|
TextBox7
|
Name
Text
|
TextBox7
|
TextBox8
|
Name
Text
|
TextBox8
|
TextBox9
|
Name
Text
|
TextBox9
|
TextBox10
|
Name
Text
|
TextBox10
|
TextBox11
|
Name
Text
|
TextBox11
|
PictureBox 1
|
Name
Text
|
PictureBox1
|
PictureBox 2
|
Name
Text
|
PictureBox2
|
OvalShape 1
|
Name
Text
|
OvalShape1
|
GroupBox 1
|
Name
Text
|
GroupBox1
Rectangle
|
GroupBox 2
|
Name
Text
|
GroupBox2
Circle
|
GroupBox 3
|
Name
Text
|
GroupBox3
Triangle
|
Analisis
Listing Program
Public Class Form1
Dim a, b, c, kelpersegi As
Integer
Dim d, luasling, kelling As
Integer
Dim f, g, luassg, h, kelseg As
Integer
*Mendeklarasikan
a,b,c,kelpersegi sebagai integer. D,luasling dan kelling sebagai integer. F,g,luassg,h,kelseg
sebagai integer
Private Sub
Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
c = a
* b
PictureBox1.Height = a
PictureBox1.Width = b
If ComboBox1.Text = ("Rectangle")
Then
PictureBox1.Show()
End If
If ComboBox1.Text = ("Circle")
Then
OvalShape1.Show()
End If
If ComboBox1.Text = ("Triangle")
Then
PictureBox2.Show()
End If
TextBox3.Text = c
kelpersegi = 2 * (a + b)
TextBox9.Text = kelpersegi
End Sub
*Menyatakan
apabila kita memilih jenis bentuk, maka akan tampil form yang sesuai dan rumus
keliling persegi
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
If e.KeyChar = vbBack Then
e.Handled = False
End Sub
*Menunjukan
bahwa TextBox1 hanya dapat diisi dengan angka saja (listing ini berlaku untuk
seluruh textbox
Private Sub
TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
TextBox1.TextChanged
a =
Val(TextBox1.Text)
End Sub
*Merubah data
string pada TextBox1 menjadi integer (a)
Private Sub
TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
TextBox2.TextChanged
b =
Val(TextBox2.Text)
End Sub
*Merubah data
string pada TextBox2 menjadi integer (b) hal ini juga berlaku pada text box
lainnya
Private Sub
ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
ComboBox1.SelectedIndexChanged
If ComboBox1.Text = ("Rectangle")
Then
Label1.Show()
Label2.Show()
Label15.Show()
Label16.Show()
TextBox1.Show()
TextBox2.Show()
Button1.Show()
TextBox3.Show()
TextBox9.Show()
GroupBox1.Show()
Label5.Hide()
Label6.Hide()
Label17.Hide()
TextBox4.Hide()
TextBox5.Hide()
TextBox10.Hide()
Button2.Hide()
GroupBox2.Hide()
GroupBox3.Hide()
Label7.Hide()
Label8.Hide()
Label9.Hide()
Label10.Hide()
Label12.Hide()
Button3.Hide()
TextBox6.Hide()
TextBox7.Hide()
TextBox8.Hide()
OvalShape1.Hide()
PictureBox2.Hide()
End If
If ComboBox1.Text = ("Circle")
Then
Label5.Show()
Label6.Show()
Label17.Show()
TextBox4.Show()
TextBox5.Show()
TextBox10.Show()
Button2.Show()
GroupBox2.Show()
Label1.Hide()
Label2.Hide()
Label15.Hide()
Label16.Hide()
TextBox1.Hide()
TextBox2.Hide()
Button1.Hide()
TextBox3.Hide()
TextBox9.Hide()
GroupBox1.Hide()
Label7.Hide()
Label8.Hide()
Label9.Hide()
Label10.Hide()
Label12.Hide()
Button3.Hide()
TextBox6.Hide()
TextBox7.Hide()
TextBox8.Hide()
PictureBox1.Hide()
PictureBox2.Hide()
GroupBox3.Hide()
Label18.Hide()
TextBox11.Hide()
End If
If ComboBox1.Text = ("Triangle")
Then
GroupBox3.Show()
Label7.Show()
Label8.Show()
Label9.Show()
Label10.Show()
Label12.Show()
Button3.Show()
TextBox6.Show()
TextBox7.Show()
TextBox8.Show()
Label1.Hide()
Label2.Hide()
Label15.Hide()
Label16.Hide()
TextBox1.Hide()
TextBox2.Hide()
Button1.Hide()
TextBox3.Hide()
TextBox9.Hide()
GroupBox1.Hide()
Label5.Hide()
Label6.Hide()
Label17.Hide()
TextBox4.Hide()
TextBox5.Hide()
TextBox10.Hide()
Button2.Hide()
GroupBox2.Hide()
PictureBox1.Hide()
OvalShape1.Hide()
End If
End Sub
*Menunjukan
bila kita ingin memilih suatu bangunan, maka yang keluar hanya form bangunan
itu saja, yang lain tetap di-hide
Private Sub
Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
PictureBox1.Hide()
PictureBox2.Hide()
Label1.Hide()
Label2.Hide()
Label5.Hide()
Label6.Hide()
TextBox1.Hide()
TextBox2.Hide()
TextBox4.Hide()
TextBox5.Hide()
OvalShape1.Hide()
Button1.Hide()
Button2.Hide()
TextBox3.Hide()
GroupBox1.Hide()
GroupBox2.Hide()
GroupBox3.Hide()
Label7.Hide()
Label8.Hide()
Label9.Hide()
Label10.Hide()
Label12.Hide()
Label17.Hide()
Button3.Hide()
TextBox6.Hide()
TextBox7.Hide()
TextBox8.Hide()
TextBox9.Hide()
TextBox10.Hide()
End Sub
*Menunjukan
tampilan awal dimana seluruh form masih disembunyikan
Private Sub
Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button2.Click
OvalShape1.Height = d * 2
OvalShape1.Width = d * 2
OvalShape1.Show()
luasling = (3.14 * d * d)
TextBox5.Text = luasling
kelling = 2 * 3.14 * d
TextBox10.Text = kelling
End Sub
*Menjelaskan
tentang cara untuk menghitung luas dan keliling lingkaran
Private Sub
Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button3.Click
PictureBox2.Height = f
PictureBox2.Width = g
PictureBox2.Show()
luassg = ((f * g) / 2)
TextBox8.Text = luassg
h =
((f / 2) ^ 2 + g ^ 2) ^ 1 / 2
kelseg = f + (2 * h)
TextBox11.Text = kelseg
End Sub
*Menjelaskan
tentang cara untuk menghitung luas dan keliling segitiga
Private Sub
Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button4.Click
Form2.Show()
Me.Hide()
End Sub
*Menjelaskan jika
kita mengklik tombol three dimensions maka akan muncul form2
Private Sub
Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button5.Click
Form3.Show()
End Sub
*Menunjukan
jika kita mengklik pada tombol exit, maka akan muncul form3
Private Sub
Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button6.Click
TextBox1.Clear()
TextBox2.Clear()
TextBox9.Clear()
TextBox3.Clear()
TextBox4.Clear()
TextBox5.Clear()
TextBox10.Clear()
TextBox6.Clear()
TextBox7.Clear()
TextBox8.Clear()
TextBox11.Clear()
End Sub
*Menunjukan
apabila kita mengklik tombol reset maka seluruh textbox akan kosong kembali
Form2
1.
Buatlah
Label1 sebagai judul dan berilah nama Geometrical Totalizer
2.
Buatlah
ComboBox untuk menampilkan jenis-jenis bangun ruang 3D
3.
Buatlah
Button-button seperti Two Dimensions, Reset dan Exit seperti ini

4.
Buatlah
Form untuk kubus seperti ini

5.
Buatlah
Form untuk Balok seperti ini

Komponen
Toolbox
Komponen
|
Properties
|
Keterangan
|
Label1
|
Name
Text
|
Label1
Geometrical Totalizer
|
Label2
|
Name
Text
|
Label2
Side
|
Label3
|
Name
Text
|
Label3
Pixel
|
Label4
|
Name
Text
|
Label4
Pixel
|
Label5
|
Name
Text
|
Label5
Length
|
Label6
|
Name
Text
|
Label6
Width
|
Label7
|
Name
Text
|
Label7
Height
|
Label8
|
Name
Text
|
Label8
Pixel
|
Label9
|
Name
Text
|
Label9
Pixel
|
Label10
|
Name
Text
|
Label10
Pixel
|
ComboBox 1
|
Name
Text
|
ComboBox1
<Select Three
Dimensions Shape>
|
Button1
|
Name
Text
|
Button1
Generate
|
Button2
|
Name
Text
|
Button2
Generate
|
Button3
|
Name
Text
|
Button3
Two Dimensions
|
Button4
|
Name
Text
|
Button4
Exit
|
Button5
|
Name
Text
|
Button5
Reset
|
GroupBox1
|
Name
Text
|
GroupBox1
Cube
|
GroupBox2
|
Name
Text
|
GroupBox2
Beam
|
TextBox1
|
Name
Text
|
TextBox1
|
TextBox2
|
Name
Text
|
TextBox2
|
TextBox3
|
Name
Text
|
TextBox3
|
TextBox4
|
Name
Text
|
TextBox4
|
TextBox5
|
Name
Text
|
TextBox5
|
TextBox6
|
Name
Text
|
TextBox6
|
Panel1
|
Name
Text
|
Panel1
|
Panel2
|
Name
Text
|
Panel2
|
Form2
|
Name
Text
|
Form2
GeometricalTotalizer
|
Form3
1.
Buatlah
Label yang bertuliskan seperti ini

2.
Buatlah
button Yes untuk keluar dari aplikasi dan button No untuk tetap di aplikasi
Komponen
ToolBox
Komponen
|
Properties
|
Keterangam
|
Label1
|
Name
Text
|
Label1
Are you sure want to
exit?
|
Form3
|
Name
Text
|
Form3
WARNING
|
Button1
|
Name
Text
|
Button1
Yes
|
Button2
|
Name
Text
|
Button2
No
|
ANALISIS LISTING PROGRAM
Public Class Form2
Dim a, volkubus As Integer
Dim p, q, r, volbalok As
Integer
*Mendeklarasikan
a,volkubus,p,q,r,volbalok sebagai integer
Private Sub
ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
ComboBox1.SelectedIndexChanged
If ComboBox1.Text = "Cube"
Then
GroupBox1.Show()
Label1.Show()
Label2.Show()
Label3.Show()
TextBox1.Show()
TextBox2.Show()
Button1.Show()
GroupBox2.Hide()
Label14.Hide()
Label5.Hide()
Label7.Hide()
Label8.Hide()
Label6.Hide()
TextBox3.Hide()
TextBox4.Hide()
TextBox5.Hide()
Button2.Hide()
End If
If ComboBox1.Text = "Beam"
Then
GroupBox2.Show()
Label14.Show()
Label5.Show()
Label7.Show()
Label8.Show()
Label6.Show()
TextBox3.Show()
TextBox4.Show()
TextBox5.Show()
Button2.Show()
GroupBox1.Hide()
Label1.Hide()
Label2.Hide()
Label3.Hide()
TextBox1.Hide()
TextBox2.Hide()
Button1.Hide()
End If
End Sub
*Menunjukan
apabila kita memilih suatu bangun ruang, maka form akan muncul sesuai dengan
yang kita inginkan
Private Sub
Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
GroupBox1.Hide()
Label1.Hide()
Label2.Hide()
Label3.Hide()
TextBox1.Hide()
TextBox2.Hide()
Button1.Hide()
GroupBox2.Hide()
Label14.Hide()
Label5.Hide()
Label7.Hide()
Label8.Hide()
Label6.Hide()
TextBox3.Hide()
TextBox4.Hide()
TextBox5.Hide()
Button2.Hide()
End Sub
*Menunjukan
tampilan awal pada form, dimana seluruh form masih disembunyikan terkecuali
button-button dan ComboBox pilihan
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
If e.KeyChar = vbBack Then
e.Handled = False
End Sub
*Menunjukan
bahwa TextBox1 hanya dapat diisi dengan angka (hal ini berlaku pada textbox
lainnya)
Private Sub
TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
TextBox1.TextChanged
a =
Val(TextBox1.Text)
End Sub
*Menunjukan
bahwa string pada TextBox1 dirubah menjadi integer (a) hal ini berlaku pada
textbox lainnya
Private Sub
Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
volkubus = a ^ 3
TextBox2.Text = volkubus
Dim myGraphics As Graphics = Panel1.CreateGraphics
Dim myPen As Pen
myPen
= New Pen(Drawing.Color.Black, 3)
Dim x1 As New Integer
Dim x2 As New Integer
Dim y1 As New Integer
Dim y2 As New Integer
Dim width As New Integer
Dim height As New Integer
Dim myRect As New Rectangle
width
= TextBox1.Text
height = TextBox2.Text
myRect.Width = TextBox1.Text
myRect.Height = TextBox1.Text
myRect.X = 10
myRect.Y = (10 + width / 2)
myGraphics.DrawRectangle(myPen, myRect)
myRect.X = (10 + width / 2)
myRect.Y
= 10
myGraphics.DrawRectangle(myPen, myRect)
x1 =
10
y1 =
(10 + width / 2)
x2 =
(10 + width / 2)
y2 =
10
myGraphics.DrawLine(myPen, x1, y1, x2, y2)
y1 =
y1 + width
y2 =
y2 + width
myGraphics.DrawLine(myPen, x1, y1, x2, y2)
x1 =
x1 + width
x2 =
x2 + width
myGraphics.DrawLine(myPen, x1, y1, x2, y2)
y1 =
y1 - width
y2 =
y2 - width
myGraphics.DrawLine(myPen, x1, y1, x2, y2)
End Sub
*Menunjukan
Volume kubus dan cara-cara agar memunculkan gambar 3 dimensi
Private Sub
Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button2.Click
volbalok = p * q * r
TextBox6.Text = volbalok
Dim myGraphics As Graphics = Panel2.CreateGraphics
Dim myPen As Pen
myPen
= New Pen(Drawing.Color.Black, 3)
Dim x1 As New Integer
Dim x2 As New Integer
Dim y1 As New Integer
Dim y2 As New Integer
Dim width As New Integer
Dim height As New Integer
Dim lebar As New Integer
Dim myRect As New Rectangle
width
= TextBox3.Text
height = TextBox5.Text
lebar
= TextBox4.Text
myRect.Width = TextBox3.Text
myRect.Height = TextBox5.Text
myRect.X = 10
myRect.Y = (10 + lebar / 2)
myGraphics.DrawRectangle(myPen, myRect)
myRect.X = (10 + lebar / 2)
myRect.Y = 10
myGraphics.DrawRectangle(myPen, myRect)
x1 =
10
y1 =
(10 + lebar / 2)
x2 =
(10 + lebar / 2)
y2 =
10
myGraphics.DrawLine(myPen, x1, y1, x2, y2)
y1 =
y1 + height
y2 =
y2 + height
myGraphics.DrawLine(myPen, x1, y1, x2, y2)
x1 =
x1 + width
x2 =
x2 + width
myGraphics.DrawLine(myPen, x1, y1, x2, y2)
y1 =
y1 - height
y2 =
y2 - height
myGraphics.DrawLine(myPen, x1, y1, x2, y2)
End Sub
*Menjelaskan
untuk menghitung volume balok dan cara-cara untuk menampilkan gambar 3dimensi
dari balok
Private Sub
Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button4.Click
Form1.Show()
Me.Close()
End Sub
*Apabila kita
mengklik pada tombol two dimensions maka akan muncul form1
Private Sub
Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button5.Click
Form3.Show()
End Sub
*Form3 akan
muncul jika kita mengklik tombol exit
Private Sub
Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button6.Click
TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
TextBox4.Clear()
TextBox5.Clear()
TextBox6.Clear()
End Sub
End Class
*Menunjukan
jika kita mengklik tombol reset, maka seluruh textbox akan kosong kembali
FLOWCHART

Untuk mendownload program, klik disini
Tidak ada komentar:
Posting Komentar