?? 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 + -