Halaman

Jumat, 30 November 2012

Modul 2 - Konsep, Flowchart, Tutorial dan Analisis Listing Program Penggambaran Bangun Dua dan Tiga Dimensi

Deskripsi Singkat
Kami membuat program untuk memilih bangun 2 dimensi atau 3 dimensi sesuai yang di inginkan oleh user pada pilihan yang tersedia pada form. Program ini memberikan kemudahan untuk user memilih ukuran yang di inginkan. Pada program ini akan ditampilkan bentuk sesuai ukuran yang di inginkan oleh user.

Tujuan dan Manfaat
Memberikan kemudahan untuk user memahami bentuk bangun 2 dimensi dan bangun 3 dimensi.
Memberikan pengertian tentang aplikasi bangun geometris.


Tutorial
Pertama-tama bukalah program Visual Basic 2010 dengan cara:
1. Klik "Start"
2. Pilih Microsoft Visual Basic 2010
3. Setelah mucul "Start Page" pilih "New Project"   
 4. Setelah muncul halaman New Project pilih “Windows Forms Application”
5. Klik “OK”
6. Selanjutnya muncul lembar kerja Visual Basic yang biasa disebut Form
   7. Form diisi dengan berbagai komponen yang didapat melalui "Toolbox"
8. Bentuk Form


 Komponen Toolbox yang digunakan
No
Komponen
Properties
Keterangan
1.
Form 1
Name
Text
Form 1
Program Bangun 2 Dimensi dan 3 Dimensi
2.
Label 1
Name
Text
Label 1
Bangun 2 Dimensi
3.
Label 2
Name
Text
Label 2
Bangun 3 Dimensi
4.
Label 3
Name
Text
Label 3
Sisi
5.
Label 4
Name
Text
Label 4
Lebar
6.
Label 5
Name
Text
Label 5
Tinggi
7.
RadioButton1
Name
Text
RadioButton
Persegi
8.
RadioButton2
Name
Text
RadioButton
Persegi Panjang
9.
RadioButton3
Name
Text
RadioButton
Kubus
10.
RadioButton4
Name
Text
RadioButton
Balok
11.
TextBox1
Name
Text
TextBox
(Dikosongkan)
12.
TextBox2
Name
Text
TextBox
(Dikosongkan)
13.
TextBox3
Name
Text
TextBox
(Dikosongkon)
14.
Button1
Name
Text
Button
Lihat
15.
Button2
Name
Text
Button
Hapus


Analisis Listing

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Text = "PROGRAM BANGUN 2 DIMENSI DAN BANGUN 3 DIMENSI"

    End Sub

Keterangan :
·         Program ini hanya menggunakan 1 form
·         Nama form ini "PROGRAM BANGUN 2 DIMENSI DAN BANGUN 3 DIMENSI"


    Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
        TextBox1.Text = ""     
        TextBox2.Text = ""
        TextBox3.Text = ""
        Label3.Text = "Panjang"
        Label4.Text = "Lebar"
        Label3.Show()
        Label4.Show()
        Label5.Hide()
        TextBox1.Show()
        TextBox2.Show()
        TextBox3.Hide()
End Sub


Keterangan :
·         Apabila RadioButton2 di klik, maka yang keluar adalah Label3 "Panjang" dan Label4 "Lebar" serta TextBox1 dan TextBox2.
·         TextBox3 dan Label 3 sembunyi.



Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If RadioButton1.Checked Then
            TextBox4.Text = Val(TextBox1.Text) ^ 2
        End If
        If RadioButton2.Checked Then
            TextBox4.Text = Val(TextBox1.Text) * Val(TextBox2.Text)
        End If
        If RadioButton3.Checked Then
            TextBox4.Text = Val(TextBox1.Text) ^ 3
        End If
        If RadioButton4.Checked Then
            TextBox4.Text = Val(TextBox1.Text) * Val(TextBox2.Text) * Val(TextBox3.Text)
        End If
        Panel1.Refresh()


Keterangan :
merupakan fungsi untuk menampilkan luas dan volume dari bangun yang ditampilkan.

    If RadioButton1.Checked = True Then

            Dim myRect As New Rectangle
            myRect.X = 10
            myRect.Y = 10
            myRect.Width = TextBox1.Text
            myRect.Height = TextBox1.Text
            Dim myPen As Pen
            myPen = New Pen(Drawing.Color.DarkGreen, 3)
            Dim myGraphics As Graphics = Panel1.CreateGraphics
            myGraphics.DrawRectangle(myPen, myRect)

Keterangan :
·         Maksud dari
Dim myRect As New Rectangle
Membuat bangun persegi
·         Letak persegi telah di sesuaikan
·         TextBox1 digunakan untuk memberikan ukuran yg diinginkan
·         Maksud dari
Dim myPen As Pen
    myPen = New Pen(Drawing.Color.DarkGreen, 3)
Untuk memberikan warna DarkGreen pada bangun
·         Maksud dari
Dim myGraphics As Graphics = Panel1.CreateGraphics
        myGraphics.DrawRectangle(myPen, myRect)
Gambar akan muncul pada panel1


ElseIf RadioButton2.Checked = True Then
            Dim myRect As New Rectangle
            myRect.X = 10
            myRect.Y = 10
            myRect.Width = TextBox1.Text
            myRect.Height = TextBox2.Text
            Dim myPen As Pen
            myPen = New Pen(Drawing.Color.DarkGoldenrod, 3)
            Dim myGraphics As Graphics = Panel1.CreateGraphics
            myGraphics.DrawRectangle(myPen, myRect)

Keterangan :
·         TextBox1 digunakan untuk panjang bangun dan TextBox2 untuk lebar bangun
·         Warna pada bangun adalah DarkGolden


ElseIf RadioButton3.Checked = True Then
            'untuk mendefinisikan objek gambar yang akan dibuat
            Dim myGraphics As Graphics = Panel1.CreateGraphics

            Dim myPen As Pen
            myPen = New Pen(Drawing.Color.DarkCyan, 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 = TextBox1.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)

Keterangan :
·          Maksud dari
Dim myGraphics As Graphics = Panel1.CreateGraphics
 Panel 1 digunakan untuk memunculkan gambar.
·          Maksud dari
Dim myPen As Pen
        myPen = New Pen(Drawing.Color.DarkCyan, 3)
    Warna dari gambar adalah DarkCyan.
·         TextBox1 digunakan untuk memberi ukuran pada sisi – sisi bangun.
·         Letak bangun telah di sesuaikan agar dapat membentuk bangun kubus.


ElseIf RadioButton4.Checked = True Then
            'untuk mendefinisikan objek gambar yang akan dibuat
            Dim myGraphics As Graphics = Panel1.CreateGraphics

            Dim myPen As Pen
            myPen = New Pen(Drawing.Color.DarkBlue, 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 = TextBox1.Text
            height = TextBox3.Text
            lebar = TextBox2.Text

            myRect.Width = TextBox1.Text
            myRect.Height = TextBox3.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 If

    End Sub

Keterangan :
·         TextBox1 untuk memberi ukuran panjang, TextBox2 untuk memberi ukuran lebar dan TextBox3 untuk memberi ukuran tinggi.


Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Panel1.Refresh()
        TextBox1.Refresh()
        TextBox2.Refresh()
        TextBox3.Refresh()
        TextBox1.Clear()
        TextBox2.Clear()
        TextBox3.Clear()


    End Sub


Keterangan :
·         Refresh () untuk menghapus gambar dan clear untuk menghapus tulisan.


Tidak ada komentar:

Posting Komentar