有条VB题目十分不了解!~求高人指点!!感谢!

来源:百度知道 编辑:UC知道 时间:2024/06/06 03:56:43
Option Explicit
Dim score!
Dim n1%, n2%, n3%, n4%, n5%, total%, msg$, msgtitle$

Private Sub Command1_Click()
Text1.Text = total
Text2.Text = n1
Text3.Text = n2
Text4.Text = n3
Text5.Text = n4
Text6.Text = n5
End Sub

Private Sub Command2_Click()
msg = "请输入分数:(-1结束)"
msgtitle = "请输入数据"
10:
score = InputBox(msg, msgtitle)
If score < 0 Or score > 100 Then
GoTo 20
Else
total = total + 1
If score >= 90 Then
n1 = n1 + 1
ElseIf score >= 80 Then
n2 = n2 + 1
ElseIf score >= 70 Then
n3 = n3 + 1
ElseIf score >= 60 Then
n4 = n4 + 1
Else
n5 = n5 + 1
End If
GoTo 10
End If
20:

End Sub

Private Sub Command3_Click()
End
End Sub

这是一个统计表格!
-1结束是那里的设定?!求高人指点!~谢谢!~

If score < 0 Or score > 100 Then
GoTo 20
......
......
......
.
.
.
.
20:

End Sub

当你输入的分数小于0或大于100,跳转至标号20,即EndSub,所以当你输入-1时也就结束了,当然你输入大于100或小于0的任何数效果是一样的。

msg自带的属性,具体有点记不得了!

If score < 0 Or score > 100 Then
这句判断,如果是-1就跳到“20:”,直接结束