Rabu, 28 November 2012

Program Bangun 2 dan 3 Dimensi

 Flowchart






Komponen
Properties
Keterangan
Form1
Name
Text
Form1
Form1
Label1
Name
Text
Label 1
Perhitungan bangun tiga dimensi
Label2
Name
Text
Label 2
Jari-jari
Label3
Name
Text
Label3
Tinggi
Label4
Name
Text
Label4
Sisi
Label5
Name
Text
Label5
Panjang
Label6
Name
Text
Label6
Lebar
Label7
Name
Text
Label7
Garis pelukis
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
Textbox7

Panel1
Name
Text
Panel1

Button1
Name
Text
Button1
Proses
Button2
Name
Text
Button2
Kembali
Button3
Name
Text
Button3
Refresh
Form2
Name
Text
Form2

Combobox1
Name
Text
Combobox1

TextBox1
Name
Text
Textbox1

Textbox2
Name
Text
Textbox2

Textbox3
Name
Text
Textbox3

Textbox4
Name
Text
Textbox4

Textbox5
Name
Text
Textbox5

Textbox6
Name
Text
Textbox6

Label1
Name
Text
Label1
 Program perhitungan dua dimensi
Label2
Name
Text
Label2
Jari-jari
Label3
Name
Text
Label3
Panjang
Label4
Name
Text
Label4
Sisi
Label5
Name
Text
Label5
Lebar
Label6
Name
Text
Label6
Luas
Label7
Name
Text
Label7
Keliling
Panel1
Name
Text
Panel1

Ovalshape1
Name
Text
Ovalshape1
Retancleshape1
Name
Text
Retancleshape1
Retancleshape2
Name
Text
Retancleshape2
Button1
Name
Text
Button1
Proses
Button2
Name
Text
Button2
Kembali
Button3
Name
Text
Button3
Refresh
Form5
Name
Text
Form5
Form5
Label1
Name
Text
Label 1
Explor your imagination
Picturebox1
Name
Text
Picturebox1

Picturebox2
Name
Text
Picturebox2


Tutorial
listing

Public Class Form5
    Private Sub Form5_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.BackColor = Color.LightPink
    End Sub

    Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
        Form4.Show()
        Me.Hide()
    End Sub

    Private Sub PictureBox2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox2.Click
        Form1.Show()
        Me.Hide()
    End Sub
End Class



listing

Public Class Form1
    Dim jari As Double
    Dim sisi As Double
    Dim pan As Double
    Dim leb As Double
    Dim tinggi As Double
    Dim lukis As Double
    Dim hasil As Double
    Dim hasil2 As Double
    Dim bangun As String
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.BackColor = Color.LightPink
        TextBox1.Hide()
        TextBox2.Hide()
        TextBox3.Hide()
        TextBox4.Hide()
        TextBox5.Hide()
        TextBox6.Hide()
        Label2.Hide()
        Label3.Hide()
        Label4.Hide()
        Label5.Hide()
        Label6.Hide()
        Label7.Hide()
        TextBox7.Enabled = False
        TextBox8.Enabled = False
        ComboBox1.Text = "Pilih Bangun"
        With ComboBox1
            .Items.Add("Tabung")
            .Items.Add("Kubus")
            .Items.Add("Balok")
            .Items.Add("Kerucut")
            .Items.Add("Bola")
        End With
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Panel1.Refresh()
        jari = Val(TextBox1.Text)
        tinggi = Val(TextBox2.Text)
        sisi = Val(TextBox3.Text)
        pan = Val(TextBox4.Text)
        leb = Val(TextBox5.Text)
        lukis = Val(TextBox6.Text)
        bangun = ComboBox1.Text
        If ComboBox1.Text = "Pilih Bangun" Then
            MsgBox("Belum Lengkap Mengisi")
            Return
        ElseIf ComboBox1.Text = "" Then
            MsgBox("Belum Lengkap Mengisi")
            Return
        ElseIf bangun = "Tabung" Then
            Dim myGraphics As Graphics = Panel1.CreateGraphics
            Dim myPen As Pen
            myPen = New Pen(Drawing.Color.DeepPink, 3)
            Dim x1 As New Integer
            Dim x2 As New Integer
            Dim y1 As New Integer
            Dim y2 As New Integer
            Dim myRect As New Rectangle
            myRect.Width = TextBox1.Text
            myRect.Height = TextBox1.Text
            myRect.X = 10
            myRect.Y = (10 + jari / 2)
            myGraphics.DrawEllipse(myPen, myRect)
            myRect.X = 10 + tinggi / 2
            myRect.Y = 10
            myGraphics.DrawEllipse(myPen, myRect)
            x1 = 10
            y1 = (10 + jari)
            x2 = (10 + tinggi / 2)
            y2 = (10 + jari / 2)
            myGraphics.DrawLine(myPen, x1, y1, x2, y2)
            x1 = x1 + jari
            x2 = x2 + jari
            myGraphics.DrawLine(myPen, x1, y1, x2, y2)
            x1 = (10 + jari / 2)
            y1 = (10 + jari / 2)
            x2 = (10 + tinggi / 2) + (jari / 2)
            y2 = 10
            myGraphics.DrawLine(myPen, x1, y1, x2, y2)
            y1 = y1 + jari
            y2 = y2 + jari
            myGraphics.DrawLine(myPen, x1, y1, x2, y2)

            hasil2 = 3.14 * jari * jari * tinggi
            hasil = (2 * 3.14 * jari * tinggi) + (2 * 3.14 * jari * jari)
        ElseIf bangun = "Kubus" Then
            Dim myGraphics As Graphics = Panel1.CreateGraphics
            Dim myPen As Pen
            myPen = New Pen(Drawing.Color.DeepPink, 3)
            Dim x1 As New Integer
            Dim x2 As New Integer
            Dim y1 As New Integer
            Dim y2 As New Integer
            Dim myRect As New Rectangle
            myRect.Width = TextBox3.Text
            myRect.Height = TextBox3.Text
            myRect.X = 10
            myRect.Y = (10 + sisi / 2)
            myGraphics.DrawRectangle(myPen, myRect)
            myRect.X = (10 + sisi / 2)
            myRect.Y = 10
            myGraphics.DrawRectangle(myPen, myRect)
            x1 = 10
            y1 = (10 + sisi / 2)
            x2 = (10 + sisi / 2)
            y2 = 10
            myGraphics.DrawLine(myPen, x1, y1, x2, y2)

            y1 = y1 + sisi
            y2 = y2 + sisi
            myGraphics.DrawLine(myPen, x1, y1, x2, y2)

            x1 = x1 + sisi
            x2 = x2 + sisi
            myGraphics.DrawLine(myPen, x1, y1, x2, y2)
            y1 = y1 - sisi
            y2 = y2 - sisi
            myGraphics.DrawLine(myPen, x1, y1, x2, y2)

            hasil = 6 * sisi * sisi
            hasil2 = sisi * sisi * sisi
        ElseIf bangun = "Balok" Then
            Dim myGraphics As Graphics = Panel1.CreateGraphics
            Dim myPen As Pen
            myPen = New Pen(Drawing.Color.DeepPink, 3)
            Dim x1 As New Integer
            Dim x2 As New Integer
            Dim y1 As New Integer
            Dim y2 As New Integer
            Dim myRect As New Rectangle

            myRect.Width = TextBox4.Text
            myRect.Height = TextBox2.Text
            myRect.X = 10
            myRect.Y = (10 + leb / 2)
            myGraphics.DrawRectangle(myPen, myRect)
            myRect.X = (10 + leb / 2)
            myRect.Y = 10
            myGraphics.DrawRectangle(myPen, myRect)

            x1 = 10
            y1 = (10 + leb / 2)
            x2 = (10 + leb / 2)
            y2 = 10
            myGraphics.DrawLine(myPen, x1, y1, x2, y2)

            y1 = y1 + tinggi
            y2 = y2 + tinggi
            myGraphics.DrawLine(myPen, x1, y1, x2, y2)

            x1 = x1 + pan
            x2 = x2 + pan
            myGraphics.DrawLine(myPen, x1, y1, x2, y2)
            y1 = y1 - tinggi
            y2 = y2 - tinggi
            myGraphics.DrawLine(myPen, x1, y1, x2, y2)

            hasil2 = pan * leb * tinggi
            hasil = 2 * (pan * leb + pan * tinggi + leb * tinggi)
        ElseIf bangun = "Kerucut" Then
            Dim myGraphics As Graphics = Panel1.CreateGraphics
            Dim myPen As Pen
            myPen = New Pen(Drawing.Color.DeepPink, 3)
            Dim x1 As New Integer
            Dim x2 As New Integer
            Dim y1 As New Integer
            Dim y2 As New Integer
            Dim myRect As New Rectangle
            myRect.Width = TextBox1.Text
            myRect.Height = TextBox1.Text
            myRect.X = 10
            myRect.Y = (10 + jari / 2)
            myGraphics.DrawEllipse(myPen, myRect)
            x1 = (10 + jari / 2)
            y1 = (10 + jari / 2)
            x2 = (10 + tinggi / 2) + (jari / 2)
            y2 = 10 + jari
            myGraphics.DrawLine(myPen, x1, y1, x2, y2)
            x1 = (10 + jari / 2)
            y1 = y1 + jari
            x2 = (10 + tinggi / 2) + (jari / 2)
            myGraphics.DrawLine(myPen, x1, y1, x2, y2)
            x1 = 10
            y1 = (10 + jari)
            myGraphics.DrawLine(myPen, x1, y1, x2, y2)
            x1 = x1 + jari
            myGraphics.DrawLine(myPen, x1, y1, x2, y2)

            hasil2 = (3.14 * jari * jari * tinggi) / 3
            hasil = (3.14 * jari * jari) + (3.14 * jari * lukis)
        ElseIf bangun = "Bola" Then
            Dim myGraphics As Graphics = Panel1.CreateGraphics
            Dim myPen As Pen
            myPen = New Pen(Drawing.Color.DeepPink, 3)
            Dim x1 As New Integer
            Dim x2 As New Integer
            Dim y1 As New Integer
            Dim y2 As New Integer
            Dim myRect As New Rectangle
            x1 = 10
            y1 = 10
            x2 = 10 + jari
            y2 = 10 + jari
            myGraphics.DrawEllipse(myPen, x1, y1, x2, y2)
            y1 = 10 + jari / 4
            y2 = 10 + jari - jari / 2
            myGraphics.DrawEllipse(myPen, x1, y1, x2, y2)
            y1 = 10 + jari / 8
            y2 = 10 + jari - jari / 4
            myGraphics.DrawEllipse(myPen, x1, y1, x2, y2)
            y1 = 10 + jari / 16
            y2 = 10 + jari - jari / 8
            myGraphics.DrawEllipse(myPen, x1, y1, x2, y2)
            y1 = 10 + jari / 2
            y2 = 10
            myGraphics.DrawEllipse(myPen, x1, y1, x2, y2)

            hasil2 = (4 * 3.14 * jari * jari * jari) / 3
            hasil = 4 * 3.14 * jari * jari
        End If
        TextBox7.Text = hasil
        TextBox8.Text = hasil2
    End Sub

    Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Me.Close()
        Form5.Show()
    End Sub

    Private Sub ComboBox1_SlectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged

        TextBox1.Text = ""
        TextBox2.Text = ""
        TextBox3.Text = ""
        TextBox4.Text = ""
        TextBox6.Text = ""
        TextBox7.Text = ""
        TextBox5.Text = ""
        TextBox8.Text = ""
        If ComboBox1.Text = "Tabung" Then
            TextBox1.Show()
            TextBox2.Show()
            TextBox3.Hide()
            TextBox4.Hide()
            TextBox5.Hide()
            TextBox6.Hide()
            Label2.Show()
            Label3.Show()
            Label4.Hide()
            Label5.Hide()
            Label6.Hide()
            Label7.Hide()
        ElseIf ComboBox1.Text = "Kubus" Then
            TextBox1.Hide()
            TextBox2.Hide()
            TextBox3.Show()
            TextBox4.Hide()
            TextBox5.Hide()
            TextBox6.Hide()
            Label2.Hide()
            Label3.Hide()
            Label4.Show()
            Label5.Hide()
            Label6.Hide()
            Label7.Hide()
        ElseIf ComboBox1.Text = "Balok" Then
            TextBox1.Hide()
            TextBox2.Show()
            TextBox3.Hide()
            TextBox4.Show()
            TextBox5.Show()
            TextBox6.Hide()
            Label2.Hide()
            Label3.Show()
            Label4.Hide()
            Label5.Show()
            Label6.Show()
            Label7.Hide()
        ElseIf ComboBox1.Text = "Kerucut" Then
            TextBox1.Show()
            TextBox2.Show()
            TextBox3.Hide()
            TextBox4.Hide()
            TextBox5.Hide()
            TextBox6.Show()
            Label2.Show()
            Label3.Show()
            Label4.Hide()
            Label5.Hide()
            Label6.Hide()
            Label7.Show()
        ElseIf ComboBox1.Text = "Bola" Then
            TextBox1.Show()
            TextBox2.Hide()
            TextBox3.Hide()
            TextBox4.Hide()
            TextBox5.Hide()
            TextBox6.Hide()
            Label2.Show()
            Label3.Hide()
            Label4.Hide()
            Label5.Hide()
            Label6.Hide()
            Label7.Hide()
        End If
    End Sub

    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 = ""
        TextBox6.Text = ""
        TextBox7.Text = ""
        TextBox5.Text = ""
        TextBox8.Text = ""
        Panel1.Refresh()

    End Sub
End Class






 listing

Public Class Form4

    Dim jari As Double
    Dim sisi As Double
    Dim pan As Double
    Dim leb As Double
    Dim hasil As Double
    Dim hasil2 As Double
    Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        TextBox5.Enabled = False
        TextBox6.Enabled = False
        ComboBox1.Text = "Pilih Bangun"
        Me.BackColor = Color.Pink
        With ComboBox1
            .Items.Add("Lingkaran")
            .Items.Add("Persegi")
            .Items.Add("Persegi Panjang")
        End With
        Me.TextBox1.Hide()
        Me.TextBox2.Hide()
        Me.TextBox3.Hide()
        Me.TextBox4.Hide()
        Me.Label2.Hide()
        Me.Label3.Hide()
        Me.Label4.Hide()
        Me.Label5.Hide()
        Me.RectangleShape1.Hide()
        Me.RectangleShape2.Hide()
        Me.OvalShape1.Hide()
    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        TextBox1.Clear()
        TextBox2.Clear()
        TextBox3.Clear()
        TextBox4.Clear()
        TextBox5.Clear()
        TextBox6.Clear()

        If Me.ComboBox1.Text = "Lingkaran" Then
            Me.TextBox1.Show()
            Me.Label2.Show()
            Me.OvalShape1.Hide()
            Me.RectangleShape1.Hide()
            Me.RectangleShape2.Hide()
            Me.TextBox2.Hide()
            Me.TextBox3.Hide()
            Me.TextBox4.Hide()
            Me.Label3.Hide()
            Me.Label4.Hide()
            Me.Label5.Hide()
        ElseIf Me.ComboBox1.Text = "Persegi" Then
            Me.TextBox2.Show()
            Me.Label3.Show()
            Me.OvalShape1.Hide()
            Me.RectangleShape1.Hide()
            Me.RectangleShape2.Hide()
            Me.TextBox1.Hide()
            Me.TextBox3.Hide()
            Me.TextBox4.Hide()
            Me.Label2.Hide()
            Me.Label4.Hide()
            Me.Label5.Hide()
        ElseIf Me.ComboBox1.Text = "Persegi Panjang" Then
            Me.Label4.Show()
            Me.Label5.Show()
            Me.TextBox4.Show()
            Me.TextBox3.Show()
            Me.OvalShape1.Hide()
            Me.RectangleShape1.Hide()
            Me.RectangleShape2.Hide()
            Me.TextBox1.Hide()
            Me.TextBox2.Hide()
            Me.Label2.Hide()
            Me.Label3.Hide()
        ElseIf ComboBox1.Text = "Pilih Bangun" Then
            MsgBox("Bangun Belum Diisi")
            Return
        ElseIf ComboBox1.Text = "" Then
            MsgBox("Bangun Belum Diisi")
            Return
        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        jari = Val(TextBox1.Text)
        sisi = Val(TextBox2.Text)
        pan = Val(TextBox3.Text)
        leb = Val(TextBox4.Text)
        If Me.ComboBox1.Text = "Lingkaran" Then
            Me.OvalShape1.Show()
            Me.OvalShape1.Height = jari
            Me.OvalShape1.Width = jari
            hasil = jari * 3.14 * jari
            hasil2 = 2 * jari * 3.14
        ElseIf Me.ComboBox1.Text = "Persegi" Then
            hasil = sisi * sisi
            hasil2 = 4 * sisi
            Me.RectangleShape1.Show()
            Me.RectangleShape1.Height = sisi
            Me.RectangleShape1.Width = sisi
        ElseIf Me.ComboBox1.Text = "Persegi Panjang" Then
            hasil = pan * leb
            hasil2 = 2 * (pan + leb)
            Me.RectangleShape2.Show()
            Me.RectangleShape2.Height = pan
            Me.RectangleShape2.Width = leb
        ElseIf ComboBox1.Text = "Pilih Bangun" Then
            MsgBox("Bangun Belum Diisi")
            Return
        ElseIf ComboBox1.Text = "" Then
            MsgBox("Bangun Belum Diisi")
            Return
        End If
        TextBox5.Text = hasil
        TextBox6.Text = hasil2
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Form5.Show()
        Me.Close()
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        TextBox1.Clear()
        TextBox2.Clear()
        TextBox3.Clear()
        TextBox4.Clear()
        TextBox5.Clear()
        TextBox6.Clear()
        Panel1.Refresh()
    End Sub
End Class


Tidak ada komentar:

Posting Komentar