adsense

2010-10-05

[vb] 簡易運算

Public Class Form1




Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click

End

End Sub



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

Label3.Visible = False 'label3隱藏

Me.Text = "簡易運算" 'title 名稱

End Sub



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



End Sub



Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Label3.Visible = True '顯示label3

Dim sun As Double = CInt(TextBox1.Text) + CInt(TextBox2.Text) 'cint 傳回一個轉換為 Integer 資料型態的運算式

Label3.Text = "加法運算:" + vbCrLf 'vbcrlf換行

Label3.Text += TextBox1.Text & "+" & TextBox2.Text & "=" & sun '注意加號

Label3.BackColor = Color.Orange '背景顏色

Label3.ForeColor = Color.Red '文字顏色

Me.BackColor = Color.WhiteSmoke '表單顏色



End Sub



Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

Label3.Visible = True '顯示label3

Dim sun As Double = CInt(TextBox1.Text) - CInt(TextBox2.Text) 'cint 傳回一個轉換為 Integer 資料型態的運算式

Label3.Text = "減法運算:" + vbCrLf 'vbcrlf換行

Label3.Text += TextBox1.Text & "-" & TextBox2.Text & "=" & sun '注意加號

Me.BackColor = Color.GreenYellow

Label3.BackColor = Color.Yellow '背景顏色

Label3.ForeColor = Color.Orange '文字顏色



End Sub



Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

Label3.Visible = True '顯示label3

Dim sun As Double = CInt(TextBox1.Text) * CInt(TextBox2.Text) 'cint 傳回一個轉換為 Integer 資料型態的運算式

Label3.Text = "乘法運算:" + vbCrLf 'vbcrlf換行

Label3.Text += TextBox1.Text & "*" & TextBox2.Text & "=" & sun '注意加號

Label3.ForeColor = Color.Yellow '文字顏色

Label3.BackColor = Color.Green '背景顏色

Me.BackColor = Color.White



End Sub



Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

Label3.Visible = True '顯示label3

Dim sun As Double = CInt(TextBox1.Text) / CInt(TextBox2.Text) 'cint 傳回一個轉換為 Integer 資料型態的運算式

Label3.Text = "除法運算:" + vbCrLf 'vbcrlf換行

Label3.Text += TextBox1.Text & "/" & TextBox2.Text & "=" & sun '注意加號

Me.BackColor = Color.YellowGreen '表單顏色

Label3.BackColor = Color.Blue '背景顏色

Label3.ForeColor = Color.Green '文字顏色



End Sub

End Class

沒有留言:

張貼留言