vb袖珍计算机模拟程序,vb编程,用selectcase编一模拟袖珍计算器(四则运算即、 爱问知识人...

Dim a As Double, b As Double, c As String

Private Sub Command1_Click()

Text1。Text = Text1。Text & "1"

End Sub

Private Sub Command10_Click()

Text1。

Text = Text1。Text & "9"

End Sub

Private Sub Command11_Click()

Text1。Text = Text1。Text & "8"

End Sub

Private Sub Command12_Click()

Text1。

Text = Text1。Text & "7"

End Sub

Private Sub Command13_Click()

Text1。Text = Text1。Text & "6"

End Sub

Private Sub Command14_Click()

Text1。

Text = Text1。Text & "5"

End Sub

Private Sub Command15_Click()

Text1。Text = Text1。Text & "4"

End Sub

Private Sub Command16_Click()

Text1。

Text = Text1。Text & "3"

End Sub

Private Sub Command17_Click()

Text1。Text = Text1。Text & "2"

End Sub

Private Sub Command2_Click()’清空

Text1。

Text = ""

Text1。SetFocus

End Sub

Dim i As Variant

If Text1。Text = "" Then Exit Sub

aa = Len(Text1。

Text)

If Text1。Text 57 Or Asc(Mid(Text1。Text, i, 1)) = 47 Then

MsgBox "非法数据,请重新输入!", 64, "提示!"

Text1。

Text = ""

Text1。SetFocus

Exit For

End If

Next i

End If

b = Val(Text1。

Text)

Select Case c

Case " "

Text1。Text = Val(a) Val(b)

Case "-"

Text1。

Text = Val(a) - Val(b)

Case "*"

If b = "0" Or a = "0" Then

MsgBox "0不可以其它数相乘,请输入正确的数据!", 16, "提示!"

Text1。

Text = ""

Text1。SetFocus

Exit Sub

End If

Text1。

Text = Val(a) * Val(b)

Case "/"

If Val(b) = 0 Then Exit Sub

If a = 0 Or b = 0 Then

MsgBox "0不可以作除数,请输入正确的数据!", 16, "提示!"

Text1。

Text = ""

Text1。SetFocus

Exit Sub

End If

Text1。Text = Val(a) / Val(b)

End Select

If IsNumeric(Text1。

Text) Then

Text1。Text = Text1。Text

End If

End Sub

Private Sub Command4_Click()

If Text1。

Text = "" Then Exit Sub

a = Text1。Text

Text1。Text = ""

c = "/"

End Sub

Private Sub Command5_Click()

If Text1。

Text = "" Then Exit Sub

a = Text1。Text

Text1。Text = ""

c = "-"

End Sub

Private Sub Command6_Click()

If Text1。

Text = "" Then Exit Sub

a = Text1。Text

Text1。Text = ""

c = "*"

End Sub

Private Sub Command7_Click()

If Text1。

Text = "" Then Exit Sub

a = Text1。Text

Text1。Text = ""

c = " "

End Sub

Private Sub Command8_Click()

If InStr(1, Text1。

Text, "。") > 0 Then Exit Sub

If Len(Text1。Text) = 0 Then Text1。Text = "0"

Text1。Text = Text1。Text & "。

"

End Sub

Private Sub Command9_Click()

Text1。Text = Text1。Text & "0"

End Sub

Private Sub Form_Load()

Text1。

fontsize = 40

End Sub

Private Sub Text1_Change()

If KeyAscii = 46 Then

If InStr(1, Text1。

Text, "。

") > 0 Then

KeyAscii = 0: Exit Sub

Else

Exit Sub

End If

End If

If KeyAscii >= 48 And KeyAscii <= 57 Then Exit Sub

If KeyAscii = 8 Or KeyAscii = 13 Then Exit Sub

If KeyAscii = 45 Then Exit Sub

KeyAscii = 0

End Sub。

全部

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值