Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.CenterToScreen()
TextBox1.Text = 15
TextBox2.Text = 5
Button1.Text = "คำนวณ"
Label3.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)
r = a + b
Label3.Text = Format(r, "###,##0.00")
TextBox1.Enabled = False
TextBox2.Enabled = False
Button1.Enabled = False
Button2.Enabled = True
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
Label3.Text = ""
TextBox1.Text = ""
TextBox2.Text = ""
End Sub
End Class |