Pada UTS Pemograman bisnis 1 kali ini saya akan membua program untuk menghitung luas bangun datar menggunakan VB.Net
Public Class Form1
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
Kedua, klik dua kali pada button Keluar,, dan ketik koding berwarna merah berikut ini :
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
End
End Sub
Ketiga,klik dua kali pada button Hitung, dan ketik koding berwarna merah berikut ini :
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