使用2个可以加倍和减半的按钮输入整数

时间:2018-07-25 18:23:23

标签: visual-studio-2017 integer double

我试图弄清楚如何输入整数(数字)并尝试配置双倍和减半按钮,以便我可以输入数字,然后将双倍减半对分,然后按任意一个按钮后将其清除。这是我的代码:

公共类表格1

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles 

Button1.Click
        Dim number As Double = 0
        If Double.TryParse(Me.txtEnterAnInteger.Text, number) Then
            25
        Else

            MessageBox.Show("Insert a number")

            Me.txtEnterAnInteger.Clear()

        End If

    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        MsgBox("Displays half the number in the text box and then clears it.")
    End Sub

    Private Sub TxtEnterAnInteger_TextChanged(sender As Object, e As EventArgs) Handles txtEnterAnInteger.TextChanged
        Dim number As Double = 0
        If Double.TryParse(Me.txtEnterAnInteger.Text, number) Then

            'your code

        Else

            MessageBox.Show("Insert a number")

            Me.txtEnterAnInteger.Clear()

        End If


    End Sub
End Class

0 个答案:

没有答案