📄 frmtestlogon.frm
字号:
VERSION 5.00
Begin VB.Form TestLogon
BorderStyle = 1 'Fixed Single
Caption = "自测考试系统客户端登录"
ClientHeight = 3630
ClientLeft = 45
ClientTop = 330
ClientWidth = 5970
ControlBox = 0 'False
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3630
ScaleWidth = 5970
StartUpPosition = 2 '屏幕中心
Begin VB.TextBox txtIP
Height = 300
Left = 2460
MaxLength = 15
TabIndex = 0
Top = 1740
Width = 1935
End
Begin VB.CommandButton cmdExit
Cancel = -1 'True
Caption = "退出"
Height = 315
Left = 3060
TabIndex = 4
Top = 3000
Width = 795
End
Begin VB.CommandButton cmdOk
Caption = "确定"
Default = -1 'True
Height = 315
Left = 2115
TabIndex = 3
Top = 3000
Width = 795
End
Begin VB.TextBox txtCode
Height = 300
Left = 2460
MaxLength = 8
TabIndex = 2
Top = 2520
Width = 1935
End
Begin VB.TextBox txtNum
Height = 300
Left = 2460
MaxLength = 8
TabIndex = 1
Top = 2130
Width = 1935
End
Begin VB.Label lblNews
AutoSize = -1 'True
Height = 180
Left = 1575
TabIndex = 10
Top = 1455
Width = 90
End
Begin VB.Label Label6
AutoSize = -1 'True
Caption = "服务器IP:"
Height = 180
Left = 1575
TabIndex = 9
Top = 1800
Width = 900
End
Begin VB.Label Label5
AutoSize = -1 'True
Caption = "准考证号:"
Height = 180
Left = 1575
TabIndex = 8
Top = 2580
Width = 900
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "考生学号:"
Height = 180
Left = 1575
TabIndex = 7
Top = 2190
Width = 900
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = $"frmTestLogon.frx":0000
Height = 720
Left = 780
TabIndex = 6
Top = 615
Width = 4410
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "请注意以下事项:"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 180
Left = 780
TabIndex = 5
Top = 315
Width = 1560
End
End
Attribute VB_Name = "TestLogon"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub cmdExit_Click()
If MsgBox("退出自测考试系统?", vbQuestion + vbYesNo, "自测考试系统") = vbYes Then
Unload Me
End If
End Sub
Private Sub cmdOk_Click()
Dim objStuLogInfo As New Recordset, objCn As New Connection, strSQL$
On Error GoTo DealError
'检验是否输入考试服务器IP地址
If Not txtIP Like "###.###.###.###" Then
MsgBox "请输入有效的考试服务器IP地址!", vbCritical, "自测考试系统登录"
txtIP.SetFocus
txtIP.SelStart = 0
txtIP.SelLength = Len(txtIP)
Exit Sub
End If
'检验是否输入学号
If Trim(txtNum) = "" Then
MsgBox "请输入学号!", vbCritical, "自测考试系统登录"
txtNum = ""
txtNum.SetFocus
Exit Sub
End If
'检验是否输入准考证号
If Trim(txtCode) = "" Then
MsgBox "请输入准考证号!", vbCritical, "自测考试系统登录"
txtCode = ""
txtCode.SetFocus
Exit Sub
End If
TestServerIP = txtIP
lblNews = "正在连接考试服务器,请等待………"
With objCn '建立数据库联接
.Provider = "SQLOLEDB"
.ConnectionString = "User ID=sa;PWD=123;Server=" & txtIP & _
";Initial Catalog=自测考试"
.Open
End With
'访问数据库获得学生登录信息
With objStuLogInfo
.CursorLocation = adUseClient '指定使用客户端游标
.Open "SELECT 学号,考号,缺考 FROM 学生信息", objCn '获取管理员登录信息
End With
With objStuLogInfo '检验学号和准考证号的合法性
If .RecordCount > 0 Then
.MoveFirst
.Find "学号='" & Trim(txtNum) & "'"
If .EOF Then
MsgBox "学号输入错误,请修改!", vbCritical, "自测考试系统登录"
txtNum.SetFocus
txtNum.SelStart = 0
txtNum.SelLength = Len(txtNum)
ElseIf .Fields("考号") <> Trim(txtCode) Then
MsgBox "准考证号输入错误,请修改!", vbCritical, "自测考试系统登录"
txtCode.SetFocus
txtCode.SelStart = 0
txtCode.SelLength = Len(txtCode)
ElseIf .Fields("缺考") = False Then
MsgBox "你已经登录或结束考试,不允许重复登录!", vbCritical, "自测考试系统登录"
Else
StudentNum = Trim(txtNum)
StudentCode = Trim(txtCode)
DoTest.Caption = "学号:" & Trim(txtNum) & " 准考证号:" & Trim(txtCode)
'修改缺考记录
strSQL = "update 学生信息 set 缺考=0 where 学号='" & StudentNum & "'"
objCn.Execute strSQL
Unload Me '关闭登录窗口
DoTest.Show '显示考试窗口
End If
End If
End With
Set objCn = Nothing
Set objStuLogInfo = Nothing
lblNews = ""
Exit Sub
DealError:
If Err.Number = -2147467259 Then
MsgBox "考试服务器IP地址错误!", vbCritical, "自测考试系统登录"
txtIP.SetFocus
txtIP.SelStart = 0
txtIP.SelLength = Len(txtIP)
Else
MsgBox "程序运行出错:" & Err.Description, vbCritical, "自测考试系统登录"
End If
Set objCn = Nothing
Set objStuLogInfo = Nothing
lblNews = ""
End Sub
Private Sub Form_Load()
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -