vb 简单成绩查询代码错在哪里?
来源:百度知道 编辑:UC知道 时间:2024/06/24 14:15:01
Option Explicit
Private Sub cmdQuery_click()
Dim intI As Integer
If txtNub = "" Then
MsgBox "查询前,请输入分数!"
Exit Sub
Else
If txtNub.Text <> 0 Then
intI = Val(txtNub.Text)
If intI = 0 Then
MsgBox "请输入正确的分数..."
Else
Select Case intI
Case intI < 60
MsgBox "不及格!"
Case intI < 80
MsgBox "及格!"
Case intI < 100
MsgBox "优秀!"
Case intI = 100
MsgBox "恭喜你,满分!"
End Select
Private Sub cmdQuery_click()
Dim intI As Integer
If txtNub = "" Then
MsgBox "查询前,请输入分数!"
Exit Sub
Else
If txtNub.Text <> 0 Then
intI = Val(txtNub.Text)
If intI = 0 Then
MsgBox "请输入正确的分数..."
Else
Select Case intI
Case intI < 60
MsgBox "不及格!"
Case intI < 80
MsgBox "及格!"
Case intI < 100
MsgBox "优秀!"
Case intI = 100
MsgBox "恭喜你,满分!"
End Select
Case intI < 60
改为Case Is < 60,在Case语句中不需要也不允许出现变量的名称,因为在Select Case语句中已经标明了
而Case intI<60中intI<60相当于一个逻辑判断语句,返回的是True(-1)或False(0),因此在输入值小于60时,这句相当于Case -1,而输入值大于60时相当于Case -1,只要你输入的值不为0或-1,它后面的代码就永远都运行不到
If txtNub = "" Then 改 If txtNub.text = "" Then
Case intI < 100 改 Case is < 100
代码---------------------
Private Sub Command1_Click()
Dim intI As Integer
If Txtnub.Text = "" Then
MsgBox "查?前,??入分?!"
Exit Sub
Else
If Txtnub.Text <> 0 Then
intI = Val(Txtnub.Text)
If intI = 0 Then
MsgBox "??入正确的分?..."
Else
Select Case intI
Case Is < 60
MsgBox "不及格!"
Case Is < 80
MsgBox "及格!"
Case Is < 100
MsgBox "优秀!"
Case Is = 100
MsgBox "恭喜你,?分!"
End Select
End If
Else