Demo entry 6660321

one

   

Submitted by anonymous on Nov 15, 2017 at 04:35
Language: VB.net. Code size: 4.0 kB.

Public Class project_1
    Dim a, b As Double
    Dim judge As Integer

    Private Sub project_1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        a = 0 '传值变量1
        b = 0 '传值变量2
        judge = 1 '存储运算符编号
    End Sub

    Private Sub two_Click(sender As Object, e As EventArgs) Handles two.Click
        If screen.Text = "0" Then
            screen.Text = "2"
        Else
            screen.Text = screen.Text + "2"
        End If
    End Sub

    Private Sub three_Click(sender As Object, e As EventArgs) Handles three.Click
        If screen.Text = "0" Then
            screen.Text = "3"
        Else
            screen.Text = screen.Text + "3"
        End If
    End Sub

    Private Sub four_Click(sender As Object, e As EventArgs) Handles four.Click
        If screen.Text = "0" Then
            screen.Text = "4"
        Else
            screen.Text = screen.Text + "4"
        End If
    End Sub

    Private Sub five_Click(sender As Object, e As EventArgs) Handles five.Click
        If screen.Text = "0" Then
            screen.Text = "5"
        Else
            screen.Text = screen.Text + "5"
        End If
    End Sub

    Private Sub six_Click(sender As Object, e As EventArgs) Handles six.Click
        If screen.Text = "0" Then
            screen.Text = "6"
        Else
            screen.Text = screen.Text + "6"
        End If
    End Sub

    Private Sub seven_Click(sender As Object, e As EventArgs) Handles seven.Click
        If screen.Text = "0" Then
            screen.Text = "7"
        Else
            screen.Text = screen.Text + "7"
        End If
    End Sub

    Private Sub eight_Click(sender As Object, e As EventArgs) Handles eight.Click
        If screen.Text = "0" Then
            screen.Text = "8"
        Else
            screen.Text = screen.Text + "8"
        End If
    End Sub

    Private Sub nine_Click(sender As Object, e As EventArgs) Handles nine.Click
        If screen.Text = "0" Then
            screen.Text = "9"
        Else
            screen.Text = screen.Text + "9"
        End If
    End Sub

    Private Sub zero_Click(sender As Object, e As EventArgs) Handles zero.Click
        If screen.Text = "0" Then
            screen.Text = "0"
        Else
            screen.Text = screen.Text + "0"
        End If
    End Sub

    Private Sub dot_Click(sender As Object, e As EventArgs) Handles dot.Click
        screen.Text = screen.Text + "."
    End Sub

    Private Sub one_Click(sender As Object, e As EventArgs) Handles one.Click
        If screen.Text = "0" Then
            screen.Text = "1"
        Else
            screen.Text = screen.Text + "1"
        End If
    End Sub

    Private Sub plus_Click(sender As Object, e As EventArgs) Handles plus.Click
        compute()
        judge = 1
    End Sub

    Private Sub minus_Click(sender As Object, e As EventArgs) Handles minus.Click
        compute()
        judge = 2
    End Sub

    Private Sub multiply_Click(sender As Object, e As EventArgs) Handles multiply.Click
        compute()
        judge = 3
    End Sub

    Private Sub divide_Click(sender As Object, e As EventArgs) Handles divide.Click
        compute()
        judge = 4
    End Sub

    Private Sub final_Click(sender As Object, e As EventArgs) Handles final.Click
        compute()
        screen.Text = b '输出运算结果
    End Sub

    Private Sub allclean_Click(sender As Object, e As EventArgs) Handles allclean.Click
        a = 0 '初始化传值变量1
        b = 0 '初始化传值变量2
        judge = 1 '初始化存储运算符编号
        screen.Text = Nothing
    End Sub

    Public Sub compute() '定义计算过程
        a = Val(screen.Text)
        Select Case judge
            Case 1
                b = b + a
            Case 2
                b = b - a
            Case 3
                b = b * a
            Case 4
                b = b / a
        End Select
        judge = 0
        screen.Text = "0"
    End Sub
End Class

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).