【加试题】小张设计了一个“加减运算测试”程序。程序启动时运行界面如右图所示。在文本框Text1中输人计算结果后单击“下一题”按钮Command1,如计算结果正确,则得分加10分,否则不加分,同时显示下一试题内容并计数,直至完成10题测试。实现上述功能的VB程序如下,但加下划线代码有错,请改正。
Dim n As Integer '为试题计数器
Dim s As Integer 's为测试得分
Dim a As Integer, b As Integer 'a,b 为运箅数
Dim c As String 'c为运算符:"+ "表示加运算,"一"表示减运算
Private Sub Command1Click()
If c ="+" Then
If a + b = Val(Text1.Text) Then
s = s + 10
End If
Else
If c ="-" Then ①
s = s + 10
End If
End If
Label2.Caption = "得分:" + Str(s)
DispTest
End Sub
Private Sub FormLoad()
Randomize
n = 0
s = 0
DispTest
End Sub
Private Sub DispTest()
n = n + 10 ②
If n < 11 Then
Label1.Caption = "试题" + Str(n) 'a,b为运算数,且要求a不小于b
a = Int(Rnd() * 100)
b = Int(Rnd() * 100)
If Rnd() > 0.5 Then c = "+" Else c = "-"
Label3.Caption = Str(a) + c + Str(b) + "="
Text1.Text = ""
Else
Command1.Caption = "完成测试"
End If
End Sub
①处正确的代码是
。
②处正确的代码是
。