主题:救命 谁帮我看看程序哪错了~
Private Sub Command1_Click()
X = MsgBox("超级学习机欢迎你!", vbOKCancel, "超级学习机")
If X = 0 Then End '选择“取消”,退出系统'
If X = 1 Then '选择“确定”,进入系统'
problemCount = InputBox("你要做的题目数:")
ReDim dynamicArr1 (1 To problemCount), dynamicArr2(1 To problemCount), dynamicArr3(1 To problemCount), dynamicArr4(1 To problemCount), dynamicArr5(1 To problemCount), dynamicArr6(1 To problemCount)
Randomize '生成1-50范围内的动态数组'
For I = 1 To problemCount
dynamicArr1(I) = Int(Rnd * 50) + 1 ' dynamicArr1(i)用来存放第一个操作数'
dynamicArr3(I) = Int(Rnd * 50) + 1 'b(i)由c(i)-d(i)生成,用来存放第二个操作数'
dynamicArr4(I) = Int(Rnd * 50) + 1
dynamicArr2(I) = dynamicArr3(I) – dynamicArr4(I)
dynamicArr5(I) = dynamicArr1(I) + dynamicArr2(I) ' dynamicArr5(i)用来存放正确答案,f(i)用来存放测试者输入的答案'
Next I
g = 0 '所属变量的初始化'
h = 0
k = 0
For I = 1 To t '反复用inputbox输出题目并让做题者输入答案'
If dynamicArr2(I) > 0 Then '如果第二个操作数大于0,输出“+”'
f(I) = InputBox(Str(dynamicArr1(I)) & "+" & Str(dynamicArr2(I)) & "=" & Chr(13) & "你的答案是:")
If f(I) = dynamicArr5(I) Then
Text1.Text = Text1.Text & Str(dynamicArr1(I)) & "+" & Str(dynamicArr2(I)) & "=" & Str(dynamicArr6(I)) & Chr(13) & Chr(10)
Text2 = Text2 & Str(dynamicArr5(I)) & Chr(13) & Chr(10)
Text3 = Text3 & "对了!" & Chr(13) & Chr(10) '在各自框内判断输入答案与正确答案的正确性'
g = g + 1
ElseIf dynamicArr6(I) <> dynamicArr5(I) Then
Text1.Text = Text1.Text & Str(dynamicArr1(I)) & "+" & Str(dynamicArr2(I)) & "=" & Str(dynamicArr6(I)) & Chr(13) & Chr(10)
Text2 = Text2 & Str(dynamicArr5(I)) & Chr(13) & Chr(10)
Text3 = Text3 & "错啦!" & Chr(13) & Chr(10)
End If
End If
If dynamicArr2(I) < 0 Then '如果第二个操作数小于0,则分下面两种情况:'
If dynamicArr5(I) > 0 Then '如果正确答案大于0,则输出如下'
f(I) = InputBox(Str(dynamicArr1(I)) & Str(dynamicArr2(I)) & "=" & Chr(13) & "你的答案是:")
If dynamicArr6(I) = dynamicArr5(I) Then
Text1.Text = Text1.Text & Str(dynamicArr1(I)) & Str(dynamicArr2(I)) & "=" & Str(dynamicArr6(I)) & Chr(13) & Chr(10)
Text2 = Text2 & Str(dynamicArr5(I)) & Chr(13) & Chr(10)
Text3 = Text3 & "答对了!" & Chr(13) & Chr(10)
h = h + 1
ElseIf dynamicArr6(I) <> dynamicArr5(I) Then
Text1.Text = Text1.Text & Str(dynamicArr1(I)) & Str(dynamicArr2(I)) & "=" & Str(dynamicArr6(I)) & Chr(13) & Chr(10)
Text2 = Text2 & Str(dynamicArr5(I)) & Chr(13) & Chr(10)
Text3 = Text3 & "答错啦!" & Chr(13) & Chr(10)
End If
End If
If e(I) < 0 Then '如果正确答案小于0,为了防止出现负数,则如下,把b(i)变成正的被减数,dynamicArr1(i)变为减数'
dynamicArr5(I) = - dynamicArr5(I)
dynamicArr6(I) = InputBox(Str(-dynamicArr2(I)) & "-" & Str(dynamicArr1(I)) & "=" & Chr(13) & "你的答案是:")
If dynamicArr6(I) = dynamicArr5(I) Then
Text1.Text = Text1.Text & Str(dynamicArr1(I)) & "+" & Str(dynamicArr2(I)) & "=" & Str(dynamicArr6(I)) & Chr(13) & Chr(10)
Text2 = Text2 & Str(dynamicArr5(I)) & Chr(13) & Chr(10)
Text3 = Text3 & "答对了!" & Chr(13) & Chr(10)
k = k + 1
ElseIf dynamicArr6(I) <> dynamicArr5(I) Then
Text1.Text = Text1.Text & Str(dynamicArr1(I)) & "+" & Str(dynamicArr2(I)) & "=" & Str(dynamicArr6(I)) & Chr(13) & Chr(10)
Text2 = Text2 & Str(dynamicArr5(I)) & Chr(13) & Chr(10)
Text3 = Text3 & "答错啦!" & Chr(13) & Chr(10)
End If
End If
End If
Next I
n = g + h + k '累加所有情况下的答对题目数'
s = n * 100 / t '评分'
End If
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Command3_Click()
Text4.Text = s '通过文本框输出分数'
End Sub
Private Sub Command4_Click()
Text1 = "" '清空所有文本框'
Text2 = ""
Text3 = ""
Text4 = ""
End Sub
主要属性值:
对象名 属性 属性值
FormTest caption 超级学习机
command1 caption 开始答题
command2 caption 退出
command3 caption 得分
command4 caption 清空
Text1
Text 清空
Multiline TRUE
Scrollbars 2 Vertical
Text2
Text 清空
Multiline TRUE
Scrollbars 2 Vertical
Text3
Text 清空
Multiline TRUE
Scrollbars 2 Vertical
Text4 caption 最后分数
我们结课的题目 有点错 找不到 希望大虾们能帮下忙 谢谢啦 急等
X = MsgBox("超级学习机欢迎你!", vbOKCancel, "超级学习机")
If X = 0 Then End '选择“取消”,退出系统'
If X = 1 Then '选择“确定”,进入系统'
problemCount = InputBox("你要做的题目数:")
ReDim dynamicArr1 (1 To problemCount), dynamicArr2(1 To problemCount), dynamicArr3(1 To problemCount), dynamicArr4(1 To problemCount), dynamicArr5(1 To problemCount), dynamicArr6(1 To problemCount)
Randomize '生成1-50范围内的动态数组'
For I = 1 To problemCount
dynamicArr1(I) = Int(Rnd * 50) + 1 ' dynamicArr1(i)用来存放第一个操作数'
dynamicArr3(I) = Int(Rnd * 50) + 1 'b(i)由c(i)-d(i)生成,用来存放第二个操作数'
dynamicArr4(I) = Int(Rnd * 50) + 1
dynamicArr2(I) = dynamicArr3(I) – dynamicArr4(I)
dynamicArr5(I) = dynamicArr1(I) + dynamicArr2(I) ' dynamicArr5(i)用来存放正确答案,f(i)用来存放测试者输入的答案'
Next I
g = 0 '所属变量的初始化'
h = 0
k = 0
For I = 1 To t '反复用inputbox输出题目并让做题者输入答案'
If dynamicArr2(I) > 0 Then '如果第二个操作数大于0,输出“+”'
f(I) = InputBox(Str(dynamicArr1(I)) & "+" & Str(dynamicArr2(I)) & "=" & Chr(13) & "你的答案是:")
If f(I) = dynamicArr5(I) Then
Text1.Text = Text1.Text & Str(dynamicArr1(I)) & "+" & Str(dynamicArr2(I)) & "=" & Str(dynamicArr6(I)) & Chr(13) & Chr(10)
Text2 = Text2 & Str(dynamicArr5(I)) & Chr(13) & Chr(10)
Text3 = Text3 & "对了!" & Chr(13) & Chr(10) '在各自框内判断输入答案与正确答案的正确性'
g = g + 1
ElseIf dynamicArr6(I) <> dynamicArr5(I) Then
Text1.Text = Text1.Text & Str(dynamicArr1(I)) & "+" & Str(dynamicArr2(I)) & "=" & Str(dynamicArr6(I)) & Chr(13) & Chr(10)
Text2 = Text2 & Str(dynamicArr5(I)) & Chr(13) & Chr(10)
Text3 = Text3 & "错啦!" & Chr(13) & Chr(10)
End If
End If
If dynamicArr2(I) < 0 Then '如果第二个操作数小于0,则分下面两种情况:'
If dynamicArr5(I) > 0 Then '如果正确答案大于0,则输出如下'
f(I) = InputBox(Str(dynamicArr1(I)) & Str(dynamicArr2(I)) & "=" & Chr(13) & "你的答案是:")
If dynamicArr6(I) = dynamicArr5(I) Then
Text1.Text = Text1.Text & Str(dynamicArr1(I)) & Str(dynamicArr2(I)) & "=" & Str(dynamicArr6(I)) & Chr(13) & Chr(10)
Text2 = Text2 & Str(dynamicArr5(I)) & Chr(13) & Chr(10)
Text3 = Text3 & "答对了!" & Chr(13) & Chr(10)
h = h + 1
ElseIf dynamicArr6(I) <> dynamicArr5(I) Then
Text1.Text = Text1.Text & Str(dynamicArr1(I)) & Str(dynamicArr2(I)) & "=" & Str(dynamicArr6(I)) & Chr(13) & Chr(10)
Text2 = Text2 & Str(dynamicArr5(I)) & Chr(13) & Chr(10)
Text3 = Text3 & "答错啦!" & Chr(13) & Chr(10)
End If
End If
If e(I) < 0 Then '如果正确答案小于0,为了防止出现负数,则如下,把b(i)变成正的被减数,dynamicArr1(i)变为减数'
dynamicArr5(I) = - dynamicArr5(I)
dynamicArr6(I) = InputBox(Str(-dynamicArr2(I)) & "-" & Str(dynamicArr1(I)) & "=" & Chr(13) & "你的答案是:")
If dynamicArr6(I) = dynamicArr5(I) Then
Text1.Text = Text1.Text & Str(dynamicArr1(I)) & "+" & Str(dynamicArr2(I)) & "=" & Str(dynamicArr6(I)) & Chr(13) & Chr(10)
Text2 = Text2 & Str(dynamicArr5(I)) & Chr(13) & Chr(10)
Text3 = Text3 & "答对了!" & Chr(13) & Chr(10)
k = k + 1
ElseIf dynamicArr6(I) <> dynamicArr5(I) Then
Text1.Text = Text1.Text & Str(dynamicArr1(I)) & "+" & Str(dynamicArr2(I)) & "=" & Str(dynamicArr6(I)) & Chr(13) & Chr(10)
Text2 = Text2 & Str(dynamicArr5(I)) & Chr(13) & Chr(10)
Text3 = Text3 & "答错啦!" & Chr(13) & Chr(10)
End If
End If
End If
Next I
n = g + h + k '累加所有情况下的答对题目数'
s = n * 100 / t '评分'
End If
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Command3_Click()
Text4.Text = s '通过文本框输出分数'
End Sub
Private Sub Command4_Click()
Text1 = "" '清空所有文本框'
Text2 = ""
Text3 = ""
Text4 = ""
End Sub
主要属性值:
对象名 属性 属性值
FormTest caption 超级学习机
command1 caption 开始答题
command2 caption 退出
command3 caption 得分
command4 caption 清空
Text1
Text 清空
Multiline TRUE
Scrollbars 2 Vertical
Text2
Text 清空
Multiline TRUE
Scrollbars 2 Vertical
Text3
Text 清空
Multiline TRUE
Scrollbars 2 Vertical
Text4 caption 最后分数
我们结课的题目 有点错 找不到 希望大虾们能帮下忙 谢谢啦 急等