2009年2月27日 星期五

四則運算

image

image

image

image

image

Public Class Form1
    Dim a As Integer
    Dim b As Integer
    Dim id As Integer
    Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
        id = 0

    End Sub
    Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged

        id = 1
    End Sub

    Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged

        id = 2
    End Sub

    Private Sub RadioButton4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton4.CheckedChanged
        id = 3

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        a = Val(TextBox1.Text)
        b = Val(TextBox2.Text)
        Select Case id
            Case 0
                TextBox3.Text = a + b
            Case 1
                TextBox3.Text = a - b
            Case 2
                TextBox3.Text = a * b
            Case 3
                TextBox3.Text = a / b
        End Select
    End Sub
End Class

沒有留言:

張貼留言