计算器vb.net 计算器免费下载( 五 )


Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
Dim tpu
If Not IsNumericRegex(TextBox1.Text) Then
tpu = MsgBox("此框中只允许输入数字!", , "错误")
If Len(TextBox1.Text)0 Then
TextBox1.Text = Microsoft.VisualBasic.Left(TextBox1.Text, Len(TextBox1.Text) - 1)
Else
TextBox1.Text = 0
End If
TextBox1.Focus()
TextBox1.SelectAll()
End If
End Sub
用vb.net做计算器的代码怎么写,其中的控件有radiobutton1234,分别代表+-*/,界面代码就不给你贴了,TextBox3显示的是结果 。
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim num1 As Integer = 0
Dim num2 As Integer = 0
Dim result As Integer = 0
Try
num1 = Integer.Parse(TextBox1.Text)
Catch ex As Exception
num1 = 0
End Try
Try
num2 = Integer.Parse(TextBox2.Text)
Catch ex As Exception
num2 = 0
End Try
If RadioButton1.Checked Then
result = num1 + num2
ElseIf RadioButton2.Checked Then
result = num1 - num2
ElseIf RadioButton3.Checked Then
result = num1 * num2
Else
result = num1 / num2
End If
TextBox3.Text = result
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End Sub
【计算器vb.net 计算器免费下载】计算器vb.net的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于计算器免费下载、计算器vb.net的信息别忘了在本站进行查找喔 。

推荐阅读