vb实现简易计算器
答案:4 悬赏:40 手机版
解决时间 2021-07-16 18:56
- 提问者网友:玫瑰园
- 2021-07-16 13:38
用vb来实现计算器,完成简单的运算。有源程序结合窗体的展示最好。
最佳答案
- 五星知识达人网友:舊物识亽
- 2021-07-16 14:56
Public num, num1 As String
Dim c As Integer
Private Sub Command1_Click()
num = ""
Text1.Text = ""
End Sub
Private Sub Command2_Click(Index As Integer)
Text1.SetFocus
num = num & Command2(Index).Caption
Text1.Text = num
End Sub
Private Sub Command3_Click()
End
End Sub
Private Sub Command4_Click()
Select Case c
Case Is = 0
num = Val(Val(num1) + Val(num))
Case Is = 1
num = Val(Val(num1) - Val(num))
Case Is = 2
num = Val(Val(num1) * Val(num))
Case Is = 3
If num = o Then
MsgBox "被除数不能为0"
Else
num = Val(Val(num1) / Val(num))
End If
End Select
Text1.Text = num
End Sub
Private Sub Command5_Click(Index As Integer)
num1 = num
num = ""
Text1.Text = ""
c = Index
End Sub
Private Sub Command6_Click()
If num <> 0 Then
num = -1 * num
Text1.Text = num
End If
End Sub
Private Sub Command7_Click()
If InStr(num, ".") Then
MsgBox "非法输入,已经存在小数点"
Else
num = num & Command7.Caption
End If
End Sub
上面是代码 昨天写给一个人的 没有保留 就随便再写了一个
Dim c As Integer
Private Sub Command1_Click()
num = ""
Text1.Text = ""
End Sub
Private Sub Command2_Click(Index As Integer)
Text1.SetFocus
num = num & Command2(Index).Caption
Text1.Text = num
End Sub
Private Sub Command3_Click()
End
End Sub
Private Sub Command4_Click()
Select Case c
Case Is = 0
num = Val(Val(num1) + Val(num))
Case Is = 1
num = Val(Val(num1) - Val(num))
Case Is = 2
num = Val(Val(num1) * Val(num))
Case Is = 3
If num = o Then
MsgBox "被除数不能为0"
Else
num = Val(Val(num1) / Val(num))
End If
End Select
Text1.Text = num
End Sub
Private Sub Command5_Click(Index As Integer)
num1 = num
num = ""
Text1.Text = ""
c = Index
End Sub
Private Sub Command6_Click()
If num <> 0 Then
num = -1 * num
Text1.Text = num
End If
End Sub
Private Sub Command7_Click()
If InStr(num, ".") Then
MsgBox "非法输入,已经存在小数点"
Else
num = num & Command7.Caption
End If
End Sub
上面是代码 昨天写给一个人的 没有保留 就随便再写了一个
全部回答
- 1楼网友:冷風如刀
- 2021-07-16 18:35
我有个计算器,简单的,没找到的话加我给你
带说话的呢
- 2楼网友:梦中风几里
- 2021-07-16 17:04
我有,而且支持小键盘输入~~~~
- 3楼网友:神的生死簿
- 2021-07-16 16:05
你好!
如果是用VB做一个计算器
方法有很多,都有很多种不同的编译手段
不知道你喜欢那一种
不过综合来说,都是一个计算器,如果你想要的
加QQ373903757
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯