今天第一天 學 VB 看書做了簡單的程式
我是 用 VB 2005 Express
簡單的加減運算

需要 3個標籤 3個文字方塊 2個按鈕 分別作 加法與 減法的計算

以下為程式碼

Public Class Form1

Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click

End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

End Sub

Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged

End Sub

Private Sub Label3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label3.Click

End Sub

Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
txtOutput.Text = Val(TextBox1.Text) + Val(TextBox2.Text)
End Sub

Private Sub btnSub_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSub.Click
txtOutput.Text = Val(TextBox1.Text) - Val(TextBox2.Text)
End Sub
End Class

做出來會像這個




創作者介紹
創作者 ip612256374 的頭像
ip612256374

↖Ι n V a D e R ╮

ip612256374 發表在 痞客邦 留言(0) 人氣()