Jumat, 16 November 2012

TUTORIAL BANGUN 2 DIMENSI DENGAN WARNA


TUTORIAL BANGUN 2 DIMENSI DENGAN WARNA




* Buka visual basic 2010
* Open file,pilih new project
* Pilih windows form application

Langkah 1
•Pertama buka Microsoft Visual Basic dan klik menu File dan pilih New Project.

Langkah 2
•Lalu pada Form 1 masukkan beberapa tool yaitu Label, Combobox, Button, Rectangleshape, Ovalshape. Label digunakan untuk mengetikkan “MACAM-MACAM BENTUK 2 DIMENSI”, “BENTUK”, DAN “WARNA”. Combobox digunakan untuk memilih bentuk bangundan memilih warna. Button digunakan untuk menjalankan perintah yang kita masukkan. Rectangle digunakan untuk membuat persegi panjang. Ovalshape digunakan untuk membuat lingkaran dan oval.

Langkah 3
•Untuk mewarnai bentuk 2D yang kita miliki yaitu menggunakan Back Color di kotak properties.


Langkah 4
•Untuk membuat bangun 2D tersebut tampak Invisible yaitu cari di kotak properties perintah visible lalu pilih false untuk membuat bangun tak terlihat ketika program dijalankan.

Langkah 5
•Cara membuatnya agar jika kita masukkan perintah maka gambar yang kita inginkan keluar adalah menggunakan fungsi IF, yaitu:

Step 1
Untuk membuat gambar muncul ketika kita memilih bangun dan warnanya

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If ComboBox1.Text = ("Lingkaran") And ComboBox2.Text = ("Merah") Then OvalShape1.Show()
        If ComboBox1.Text = ("Lingkaran") And ComboBox2.Text = ("Kuning") Then OvalShape2.Show()
        If ComboBox1.Text = ("Lingkaran") And ComboBox2.Text = ("Hijau") Then OvalShape3.Show()
        If ComboBox1.Text = ("Persegi panjang") And ComboBox2.Text = ("Merah") Then RectangleShape1.Show()
        If ComboBox1.Text = ("Persegi panjang") And ComboBox2.Text = ("Kuning") Then RectangleShape2.Show()
        If ComboBox1.Text = ("Persegi panjang") And ComboBox2.Text = ("Hijau") Then RectangleShape3.Show()
        If ComboBox1.Text = ("Oval") And ComboBox2.Text = ("Merah") Then OvalShape4.Show()
        If ComboBox1.Text = ("Oval") And ComboBox2.Text = ("Kuning") Then OvalShape5.Show()
        If ComboBox1.Text = ("Oval") And ComboBox2.Text = ("Hijau") Then OvalShape6.Show()
Step 2
Untuk membuat gambar yang sudah kita pilih akan menghilang jika kita masukkan bangun yang lain.


1. Lingkaran merah


If ComboBox1.Text = ("Lingkaran") And ComboBox2.Text = ("Kuning") Then OvalShape1.Hide()
        If ComboBox1.Text = ("Lingkaran") And ComboBox2.Text = ("Hijau") Then OvalShape1.Hide()
        If ComboBox1.Text = ("Persegi panjang") And ComboBox2.Text = ("Merah") Then OvalShape1.Hide()
        If ComboBox1.Text = ("Persegi panjang") And ComboBox2.Text = ("Kuning") Then OvalShape1.Hide()
        If ComboBox1.Text = ("Persegi panjang") And ComboBox2.Text = ("Hijau") Then OvalShape1.Hide()
        If ComboBox1.Text = ("Oval") And ComboBox2.Text = ("Merah") Then OvalShape1.Hide()
        If ComboBox1.Text = ("Oval") And ComboBox2.Text = ("Kuning") Then OvalShape1.Hide()
        If ComboBox1.Text = ("Oval") And ComboBox2.Text = ("Hijau") Then OvalShape1.Hide()
2. Lingkaran kuning


        If ComboBox1.Text = ("Lingkaran") And ComboBox2.Text = ("Merah") Then OvalShape2.Hide()
        If ComboBox1.Text = ("Lingkaran") And ComboBox2.Text = ("Hijau") Then OvalShape2.Hide()
        If ComboBox1.Text = ("Persegi panjang") And ComboBox2.Text = ("Merah") Then OvalShape2.Hide()
        If ComboBox1.Text = ("Persegi panjang") And ComboBox2.Text = ("Kuning") Then OvalShape2.Hide()
        If ComboBox1.Text = ("Persegi panjang") And ComboBox2.Text = ("Hijau") Then OvalShape2.Hide()
        If ComboBox1.Text = ("Oval") And ComboBox2.Text = ("Merah") Then OvalShape2.Hide()
        If ComboBox1.Text = ("Oval") And ComboBox2.Text = ("Kuning") Then OvalShape2.Hide()
        If ComboBox1.Text = ("Oval") And ComboBox2.Text = ("Hijau") Then OvalShape2.Hide()
3. Lingkaran Hijau


        If ComboBox1.Text = ("Lingkaran") And ComboBox2.Text = ("Merah") Then OvalShape3.Hide()
        If ComboBox1.Text = ("Lingkaran") And ComboBox2.Text = ("Kuning") Then OvalShape3.Hide()
        If ComboBox1.Text = ("Persegi panjang") And ComboBox2.Text = ("Merah") Then OvalShape3.Hide()
        If ComboBox1.Text = ("Persegi panjang") And ComboBox2.Text = ("Kuning") Then OvalShape3.Hide()
        If ComboBox1.Text = ("Persegi panjang") And ComboBox2.Text = ("Hijau") Then OvalShape3.Hide()
        If ComboBox1.Text = ("Oval") And ComboBox2.Text = ("Merah") Then OvalShape3.Hide()
        If ComboBox1.Text = ("Oval") And ComboBox2.Text = ("Kuning") Then OvalShape3.Hide()
        If ComboBox1.Text = ("Oval") And ComboBox2.Text = ("Hijau") Then OvalShape3.Hide()
4. Persegi panjang merah


        If ComboBox1.Text = ("Lingkaran") And ComboBox2.Text = ("Merah") Then RectangleShape1.Hide()
        If ComboBox1.Text = ("Lingkaran") And ComboBox2.Text = ("Kuning") Then RectangleShape1.Hide()
        If ComboBox1.Text = ("Lingkaran") And ComboBox2.Text = ("Hijau") Then RectangleShape1.Hide()
        If ComboBox1.Text = ("Persegi panjang") And ComboBox2.Text = ("Kuning") Then RectangleShape1.Hide()
        If ComboBox1.Text = ("Persegi panjang") And ComboBox2.Text = ("Hijau") Then RectangleShape1.Hide()
        If ComboBox1.Text = ("Oval") And ComboBox2.Text = ("Merah") Then RectangleShape1.Hide()
        If ComboBox1.Text = ("Oval") And ComboBox2.Text = ("Kuning") Then RectangleShape1.Hide()
        If ComboBox1.Text = ("Oval") And ComboBox2.Text = ("Hijau") Then RectangleShape1.Hide()
5. Persegi panjang kuning





        If ComboBox1.Text = ("Lingkaran") And ComboBox2.Text = ("Merah") Then RectangleShape2.Hide()
        If ComboBox1.Text = ("Lingkaran") And ComboBox2.Text = ("Kuning") Then RectangleShape2.Hide()
        If ComboBox1.Text = ("Lingkaran") And ComboBox2.Text = ("Hijau") Then RectangleShape2.Hide()
        If ComboBox1.Text = ("Persegi panjang") And ComboBox2.Text = ("Merah") Then RectangleShape2.Hide()
        If ComboBox1.Text = ("Persegi panjang") And ComboBox2.Text = ("Hijau") Then RectangleShape2.Hide()
        If ComboBox1.Text = ("Oval") And ComboBox2.Text = ("Merah") Then RectangleShape2.Hide()
        If ComboBox1.Text = ("Oval") And ComboBox2.Text = ("Kuning") Then RectangleShape2.Hide()
        If ComboBox1.Text = ("Oval") And ComboBox2.Text = ("Hijau") Then RectangleShape2.Hide()
6. Persegi panjang hijau


        If ComboBox1.Text = ("Lingkaran") And ComboBox2.Text = ("Merah") Then rectangleshape3.hide()
        If ComboBox1.Text = ("Lingkaran") And ComboBox2.Text = ("Kuning") Then RectangleShape3.Hide()
        If ComboBox1.Text = ("Lingkaran") And ComboBox2.Text = ("Hijau") Then RectangleShape3.Hide()
        If ComboBox1.Text = ("Persegi panjang") And ComboBox2.Text = ("Merah") Then RectangleShape3.Hide()
        If ComboBox1.Text = ("Persegi panjang") And ComboBox2.Text = ("Kuning") Then RectangleShape3.Hide()
        If ComboBox1.Text = ("Oval") And ComboBox2.Text = ("Merah") Then RectangleShape3.Hide()
        If ComboBox1.Text = ("Oval") And ComboBox2.Text = ("Kuning") Then RectangleShape3.Hide()
        If ComboBox1.Text = ("Oval") And ComboBox2.Text = ("Hijau") Then RectangleShape3.Hide()
7. Oval merah


        If ComboBox1.Text = ("Lingkaran") And ComboBox2.Text = ("Merah") Then OvalShape4.Hide()
        If ComboBox1.Text = ("Lingkaran") And ComboBox2.Text = ("Kuning") Then OvalShape4.Hide()
        If ComboBox1.Text = ("Lingkaran") And ComboBox2.Text = ("Hijau") Then OvalShape4.Hide()
        If ComboBox1.Text = ("Persegi panjang") And ComboBox2.Text = ("Merah") Then OvalShape4.Hide()
        If ComboBox1.Text = ("Persegi panjang") And ComboBox2.Text = ("Kuning") Then OvalShape4.Hide()
        If ComboBox1.Text = ("Persegi panjang") And ComboBox2.Text = ("Hijau") Then OvalShape4.Hide()
        If ComboBox1.Text = ("Oval") And ComboBox2.Text = ("Kuning") Then OvalShape4.Hide()
        If ComboBox1.Text = ("Oval") And ComboBox2.Text = ("Hijau") Then OvalShape4.Hide()
8. Oval kuning


        If ComboBox1.Text = ("Lingkaran") And ComboBox2.Text = ("Merah") Then OvalShape5.Hide()
        If ComboBox1.Text = ("Lingkaran") And ComboBox2.Text = ("Kuning") Then OvalShape5.Hide()
        If ComboBox1.Text = ("Lingkaran") And ComboBox2.Text = ("Hijau") Then OvalShape5.Hide()
        If ComboBox1.Text = ("Persegi panjang") And ComboBox2.Text = ("Merah") Then OvalShape5.Hide()
        If ComboBox1.Text = ("Persegi panjang") And ComboBox2.Text = ("Kuning") Then OvalShape5.Hide()
        If ComboBox1.Text = ("Persegi panjang") And ComboBox2.Text = ("Hijau") Then OvalShape5.Hide()
        If ComboBox1.Text = ("Oval") And ComboBox2.Text = ("Merah") Then OvalShape5.Hide()
        If ComboBox1.Text = ("Oval") And ComboBox2.Text = ("Hijau") Then OvalShape5.Hide()
9. Oval hijau


        If ComboBox1.Text = ("Lingkaran") And ComboBox2.Text = ("Merah") Then OvalShape6.Hide()
        If ComboBox1.Text = ("Lingkaran") And ComboBox2.Text = ("Kuning") Then OvalShape6.Hide()
        If ComboBox1.Text = ("Lingkaran") And ComboBox2.Text = ("Hijau") Then OvalShape6.Hide()
        If ComboBox1.Text = ("Persegi panjang") And ComboBox2.Text = ("Merah") Then OvalShape6.Hide()
        If ComboBox1.Text = ("Persegi panjang") And ComboBox2.Text = ("Kuning") Then OvalShape6.Hide()
        If ComboBox1.Text = ("Persegi panjang") And ComboBox2.Text = ("Hijau") Then OvalShape6.Hide()
        If ComboBox1.Text = ("Oval") And ComboBox2.Text = ("Merah") Then OvalShape6.Hide()
        If ComboBox1.Text = ("Oval") And ComboBox2.Text = ("Kuning") Then OvalShape6.Hide()

Step 3
Membuat agar tidak bisa memunculkan gambar apabila pilihan bangun dan warna belum dipilih
If ComboBox1.Text = "" Or ComboBox2.Text = "" Then
            MsgBox("SILAHKAN PILIH BANGUN/WARNA")
        End If
    End Sub

Step 4
Untuk menutup program apabila telah selesai menggunakanya
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Close()
    End Sub
   
End Class


Tidak ada komentar:

Posting Komentar