我用VB做一个判断,判断如下:如果学生的每门课都大于60则为及格,但不知为什么总不执行,望赐教
if Val(Text2.Text) > 60 And Val(Text3.Text) > 60 And Val(Text4.Text) > 60 And Val(Text5.Text) > 60 And Val(Text6.Text) > 60 And Val(Text7.Text) > 60 And _
Val(Text8.Text) > 60 Then
Label9.Caption = "该学生已经被录取!"
End If
if Val(Text2.Text) > 60 And Val(Text3.Text) > 60 And Val(Text4.Text) > 60 And Val(Text5.Text) > 60 And Val(Text6.Text) > 60 And Val(Text7.Text) > 60 And _
Val(Text8.Text) > 60 Then
Label9.Caption = "该学生已经被录取!"
End If
Dim flag As Integer
Dim panduan As IntegerDim count As Integer
Dim mrc As New ADODB.Recordset
Dim txtsql As String
Dim msgtext As String
Dim cn As New ADODB.Connection
cn.Open ConnectionString
If Trim(Text1.Text) = "" Then
MsgBox "请输入检索词"
Exit Sub
End If
If Combo1.Text = "身份证号" Then
txtsql = "select * from StuInfo where IDcardnumber='" & Trim(Text1.Text) & "'"
Set mrc = ExecuteSQL(txtsql, msgtext)
mrc.Open txtsql, cn, adOpenStatic, adLockReadOnly
If mrc.EOF = True Then
MsgBox "不存在该身份证号,请重新输入!"
mrc.Close
Else
Text2.Text = mrc.Fields("StuName")
Text3.Text = mrc.Fields("Mathscore")
Text4.Text = mrc.Fields("Languagescore")
Text5.Text = mrc.Fields("Englishscore")
Text6.Text = mrc.Fields("Physicsscore")
Text7.Text = mrc.Fields("Chemistryscore")
Text8.Text = mrc.Fields("Biologyscore")
Text9.Text = mrc.Fields("Totalscore")
mrc.Close
End If
End IfIf Combo1.Text = "准考证号" Then
txtsql = "select * from StuInfo where StuID='" & Trim(Text1.Text) & "'"
Set mrc = ExecuteSQL(txtsql, msgtext)
mrc.Open txtsql, cn, adOpenStatic, adLockReadOnly
If mrc.EOF = True Then
MsgBox "不存在该准考证号,请重新输入!"
Else
Text2.Text = mrc.Fields("StuName")
Text3.Text = mrc.Fields("Mathscore")
Text4.Text = mrc.Fields("Languagescore")
Text5.Text = mrc.Fields("Englishscore")
Text6.Text = mrc.Fields("Physicsscore")
Text7.Text = mrc.Fields("Chemistryscore")
Text8.Text = mrc.Fields("Biologyscore")
Text9.Text = mrc.Fields("Totalscore")
End IfIf Val(Text2.Text) > 60 And Val(Text3.Text) > 60 And Val(Text4.Text) > 60 And Val(Text5.Text) > 60 And Val(Text6.Text) > 60 And Val(Text7.Text) > 60 And _
Val(Text8.Text) > 60 Then
Label9.Caption = "该学生已经被录取!"
End If
If Val(Text2.Text) < 60 Then
count = count + 1
End IfIf Val(Text3.Text) < 60 Then
count = count + 1
End IfIf Val(Text4.Text) < 60 Then
count = count + 1
End IfIf Val(Text5.Text) < 60 Then
count = count + 1
End IfIf Val(Text6Text) < 60 Then
count = count + 1
End IfIf Val(Text7.Text) < 60 Then
count = count + 1
End IfIf Val(Text8.Text) < 60 Then
count = count + 1
End If
If count > 1 Then
Label9.Caption = "该学生没有被录取!"
Else
If Val(Text2.Text) < 50 Or Val(Text3.Text) < 50 Or Val(Text4.Text) < 50 Or Val(Text5.Text) < 50 Or Val(Text6.Text) < 50 Or _
Val(Text7Text) < 50 Or Val(Text8.Text) < 50 Then
panduan = 1
End IfIf panduan = 1 Then
Label9.Caption = "该学生没有被录取!"
Else
If Val(Text9.Text) / 6 > 60 Then
Label9.Caption = "该学生已经被录取!"
End If
End IfEnd If
End If
End Sub 这是代码还是那句话不执行
这句中的 mrc.Fields("StuName")的值是指“学生名字”(估计为非数字)而不是为“分数”(数字)吧?
dim bolP as boolean
bolP=True
for intP=1 to 100
bolP=(bolP and (txtFen(intP)>60))
next intP
if bolP then label1.caption="你被录取了"你只需要把你的文本框改为控件数组就是了,代码简洁的多。