我试图弄清楚如何输入整数(数字)并尝试配置双倍和减半按钮,以便我可以输入数字,然后将双倍减半对分,然后按任意一个按钮后将其清除。这是我的代码:
公共类表格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