vb四则运算
答案:1 悬赏:80 手机版
解决时间 2021-08-14 00:16
- 提问者网友:抽煙菂渘情少年
- 2021-08-13 14:08
两个窗口,第一个为数字和确定按钮,第二个是加减乘除级别的选择,除法要求是整除,第一个窗口打开后,默认为加法,一位数与一位数的运算
最佳答案
- 五星知识达人网友:长青诗
- 2021-08-13 15:27
Dim a, b, i, j, h As Integer, c(1 To 4), d As StringPrivate Sub Command1_Click()a = Int(Rnd * 11)b = Int((Rnd * 10) + 1)c(1) = "+": c(2) = "-": c(3) = "*": c(4) = "/"j = Int((Rnd * 4) + 1)d = c(j)Label1.Caption = a & d & b & "=" & "?"Label1.RefreshCommand1.Enabled = FalseEnd SubPrivate Sub Command2_Click()i = i + 1If d = c(1) Then If Text1.Text = a + b Then MsgBox "恭喜你,计算正确" h = h + 1 Text1.Text = "" Command1.Enabled = True Label2.Caption = "共" & i & "道题," & "答对" & h & "道题。" Label2.Refresh Else MsgBox "真遗憾,计算错误" Text1.Text = "" Command1.Enabled = True Label2.Caption = "共" & i & "道题," & "答对" & h & "道题。" Label2.Refresh End IfElseIf d = c(2) Then If Text1.Text = a - b Then MsgBox "恭喜你,计算正确" h = h + 1 Text1.Text = "" Command1.Enabled = True Label2.Caption = "共" & i & "道题," & "答对" & h & "道题。" Label2.Refresh Else MsgBox "真遗憾,计算错误" Text1.Text = "" Command1.Enabled = True Label2.Caption = "共" & i & "道题," & "答对" & h & "道题。" Label2.Refresh End IfElseIf d = c(3) Then If Text1.Text = a * b Then MsgBox "恭喜你,计算正确" h = h + 1 Text1.Text = "" Command1.Enabled = True Label2.Caption = "共" & i & "道题," & "答对" & h & "道题。" Label2.Refresh Else MsgBox "真遗憾,计算错误" Text1.Text = "" Command1.Enabled = True Label2.Caption = "共" & i & "道题," & "答对" & h & "道题。" Label2.Refresh End IfElseIf d = c(4) Then If CDbl(Text1.Text) = a / b Then MsgBox "恭喜你,计算正确" h = h + 1 Text1.Text = "" Command1.Enabled = True Label2.Caption = "共" & i & "道题," & "答对" &
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯