Public Class Form3
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ComboBox1.Items.Add("บวก")
ComboBox1.Items.Add("ลบ")
ComboBox1.Items.Add("คูณ")
ComboBox1.Items.Add("หาร")
ComboBox1.SelectedIndex = 1
ComboBox1.DropDownStyle = ComboBoxStyle.DropDownList
TextBox1.Text = 15
TextBox2.Text = 5
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)
Selact Case ComboBox1.SelectedIndex
Case 0
r = a + b
Case 1
r = a - b
Case 2
r = a * b
Case 3
r = a / b
End Select
Label4.Text = Foemat(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
Label4.Text = ""
TextBox1.Text = ""
TextBox2.Text = ""
End Sub
End Class
Top |