Public Class Form2
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.CenterToScreen()
Label1.Text = "ป้อนค่าที่ 1"
Label2.Text = "ป้อนค่าที่ 2"
TextBox1.Text = "15"
TextBox2.Text = "5"
RadioButton1.Text = "บวก"
RadioButton2.Text = "ลบ"
RadioButton3.Text = "คูณ"
RadioButton4.Text = "หาร"
RadioButton1.Checked = True
Button1.Text = "คำนวณ"
Button2.Text = "ล้าง"
Label4.Text = ""
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a, b As Integer
Dim r As Single
a = Val(TextBox1.Text)
b = Val(TextBox2.Text)
If RadioButton1.Checked = True Then
r = a + b
End If
If RadioButton2.Checked = True Then
r = a - b
End If
If RadioButton3.Checked = True Then
r = a * b
End If
If RadioButton4.Checked = True Then
r = a / b
End If
Label4.Text = Format(r, "###,##0.00")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TextBox1.Enabled = True
TextBox2.Enabled = True
Button1.Enabled = True
Button2.Enabled = False
Label2.Text = ""
TextBox1.Text = ""
TextBox2.Text = ""
End Sub
End Class
Top
|