Salam Super !! ![]()
hehe mulai lagi nih berkoding-koding ria pake VB euy... maklum baru belajar jadi lagi jatuh cinta gitu dah ama VB ![]()
Koding saya kali ini lagi lagi masih sangat sederhana.. jadi harap maklum yak ..
Ok dah sesuai dengan judul, bahan - bahan yang kita butuhkan adalah 4 buah label, 1 buah ComboBox , 2 TextBox, dan yang terakhir 3 buah Button... Nah bahan - bahan tersebut bisa di drag dari ToolBox yang ada pada VB.Gini nih bentuk ToolBoxnya :
kemudian ubah propertiesnya:
menjadi
Setelah tahap-tahap di atas dilakukan,maka interfacenya akan berubah wujud menjadi seperti ini :
Hmm mendesain interfacenya udah, sekarang giliran bikin kodingnya... Caranya :
Pertama, klik dua kali (double click) pada button OK,, lalu muncul Form1.vb.. dan ketik koding berwarna merah berikut ini :
Public Class Form1Kedua, klik dua kali pada button Keluar,, dan ketik koding berwarna merah berikut ini :
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If (ComboBox1.Text = "Lingkaran") Then
Label2.Visible = True
Label2.Text = "Jari-Jari"
TextBox1.Visible = True
Label3.Visible = False
TextBox2.Visible = False
Button3.Visible = True
Button1.Visible = False
Button2.Visible = False
End If
If (ComboBox1.Text = "Persegi") Then
Label2.Visible = True
Label2.Text = "Sisi"
TextBox1.Visible = True
Label3.Visible = False
TextBox2.Visible = False
Button3.Visible = True
Button1.Visible = False
Button2.Visible = False
End If
If (ComboBox1.Text = "Persegi Panjang") Then
Label2.Visible = True
Label2.Text = "Panjang"
TextBox1.Visible = True
Label3.Visible = True
Label3.Text = "Lebar"
TextBox2.Visible = True
Button3.Visible = True
Button1.Visible = False
Button2.Visible = False
End If
If (ComboBox1.Text = "Segitiga") Then
Label2.Visible = True
Label2.Text = "Alas"
TextBox1.Visible = True
Label3.Visible = True
Label3.Text = "Tinggi"
TextBox2.Visible = True
Button3.Visible = True
Button1.Visible = False
Button2.Visible = False
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.ClickKetiga,klik dua kali pada button Hitung, dan ketik koding berwarna merah berikut ini :
End
End Sub
Keempat, eksekusi program tersebut dengan menekan tombol F5 atau klik Start Debugging.Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If (ComboBox1.Text = "Lingkaran") Then
Label4.Visible = True
Dim Hasil As Double
Hasil = 3.14 * Val(TextBox1.Text) * Val(TextBox1.Text)
Label4.Text = "Luas = " & Hasil
End If
If (ComboBox1.Text = "Persegi") Then
Label4.Visible = True
Dim Hasil As Double
Hasil = Val(TextBox1.Text) * Val(TextBox1.Text)
Label4.Text = "Luas = " & Hasil
End If
If (ComboBox1.Text = "Persegi Panjang") Then
Label4.Visible = True
Dim Hasil As Double
Hasil = Val(TextBox1.Text) * Val(TextBox2.Text)
Label4.Text = "Luas = " & Hasil
End If
If (ComboBox1.Text = "Segitiga") Then
Label4.Visible = True
Dim Hasil As Double
Hasil = Val(TextBox1.Text) * Val(TextBox2.Text) / 2
Label4.Text = "Luas = " & Hasil
End If
End Sub
End Class
Selesai....


4 komentar:
wah sipppp..
wah sipppp..
makasih banyak :D
ok....
top ...