|
本帖最后由 zjdh 于 2011-8-28 09:30 编辑
2个地方需修改:
登录:
Private Sub CommandButton1_Click()
Dim arr, j As String, R&, i&, k&
Static Num1&
With Sheets("学生考试信息登记表")
R = .Range("A65536").End(xlUp).Row
arr = .Range("A2:F" & R) '修改
End With
If TextXH.Value = "" Then
MsgBox "学号不能为空"
TextXH.SetFocus
Exit Sub
End If
If TextXM.Value = "" Then
MsgBox "姓名不能为空"
TextXM.SetFocus
Exit Sub
End If
Y1 = 0
For i = 1 To UBound(arr)
If Val(arr(i, 1)) = TextXH.Value Then
If arr(i, 2) = TextXM.Value Then
MsgBox "登录成功!"
'*********修改
If arr(i, 6) = "已考" Then
For Each SH In Sheets
If InStr(SH.Name, TextXM) Then
SH.Protect Password:="2008"
MsgBox "考试已结束,不可修改!"
Exit For
End If
Next
End If
'**************
Application.Visible = True
Unload UserForm1
If arr(i, 4) = "" Then
k = Int(4 * Rnd + 3)
Sheets("学生考试信息登记表").Cells(i + 1, 4) = Sheets(k).Name
Worksheets(k).Copy after:=Worksheets(Sheets.Count)
With ActiveSheet
.Name = TextXM.Value & "考试试卷" & Sheets(k).Name '加了试卷的分类号
.Range("B2") = TextXH.Value
.Range("D2") = TextXM.Value
.Range("F2") = arr(i, 3)
End With
ElseIf arr(i, 4) <> "" Then
j = TextXM.Value & "考试试卷" & arr(i, 4)
Sheets(j).Select
Call 计时 '调用计时
End If
End If
Exit Sub
End If
Next i
MsgBox "学号或姓名出错,请重新输入!"
Num1 = Num1 + 1
If Num1 = 3 Then
MsgBox "学号或姓名已连续输入3次错误,将退出系统!", 64, "登录窗口温馨提示"
Application.Quit
Exit Sub
End If
TextXH.SetFocus
End Sub |
|