?? frmtestlogon.frm
字號(hào):
VERSION 5.00
Begin VB.Form TestLogon
BorderStyle = 1 'Fixed Single
Caption = "自測(cè)考試系統(tǒng)客戶端登錄"
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 = "服務(wù)器IP:"
Height = 180
Left = 1575
TabIndex = 9
Top = 1800
Width = 900
End
Begin VB.Label Label5
AutoSize = -1 'True
Caption = "準(zhǔn)考證號(hào):"
Height = 180
Left = 1575
TabIndex = 8
Top = 2580
Width = 900
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "考生學(xué)號(hào):"
Height = 180
Left = 1575
TabIndex = 7
Top = 2190
Width = 900
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 = "請(qǐng)注意以下事項(xiàng):"
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("退出自測(cè)考試系統(tǒng)?", vbQuestion + vbYesNo, "自測(cè)考試系統(tǒng)") = 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
'檢驗(yàn)是否輸入考試服務(wù)器IP地址
If Not txtIP Like "###.###.###.###" Then
MsgBox "請(qǐng)輸入有效的考試服務(wù)器IP地址!", vbCritical, "自測(cè)考試系統(tǒng)登錄"
txtIP.SetFocus
txtIP.SelStart = 0
txtIP.SelLength = Len(txtIP)
Exit Sub
End If
'檢驗(yàn)是否輸入學(xué)號(hào)
If Trim(txtNum) = "" Then
MsgBox "請(qǐng)輸入學(xué)號(hào)!", vbCritical, "自測(cè)考試系統(tǒng)登錄"
txtNum = ""
txtNum.SetFocus
Exit Sub
End If
'檢驗(yàn)是否輸入準(zhǔn)考證號(hào)
If Trim(txtCode) = "" Then
MsgBox "請(qǐng)輸入準(zhǔn)考證號(hào)!", vbCritical, "自測(cè)考試系統(tǒng)登錄"
txtCode = ""
txtCode.SetFocus
Exit Sub
End If
TestServerIP = txtIP
lblNews = "正在連接考試服務(wù)器,請(qǐng)等待………"
With objCn '建立數(shù)據(jù)庫(kù)聯(lián)接
.Provider = "SQLOLEDB"
.ConnectionString = "User ID=sa;PWD=123;Server=" & txtIP & _
";Initial Catalog=自測(cè)考試"
.Open
End With
'訪問(wèn)數(shù)據(jù)庫(kù)獲得學(xué)生登錄信息
With objStuLogInfo
.CursorLocation = adUseClient '指定使用客戶端游標(biāo)
.Open "SELECT 學(xué)號(hào),考號(hào),缺考 FROM 學(xué)生信息", objCn '獲取管理員登錄信息
End With
With objStuLogInfo '檢驗(yàn)學(xué)號(hào)和準(zhǔn)考證號(hào)的合法性
If .RecordCount > 0 Then
.MoveFirst
.Find "學(xué)號(hào)='" & Trim(txtNum) & "'"
If .EOF Then
MsgBox "學(xué)號(hào)輸入錯(cuò)誤,請(qǐng)修改!", vbCritical, "自測(cè)考試系統(tǒng)登錄"
txtNum.SetFocus
txtNum.SelStart = 0
txtNum.SelLength = Len(txtNum)
ElseIf .Fields("考號(hào)") <> Trim(txtCode) Then
MsgBox "準(zhǔn)考證號(hào)輸入錯(cuò)誤,請(qǐng)修改!", vbCritical, "自測(cè)考試系統(tǒng)登錄"
txtCode.SetFocus
txtCode.SelStart = 0
txtCode.SelLength = Len(txtCode)
ElseIf .Fields("缺考") = False Then
MsgBox "你已經(jīng)登錄或結(jié)束考試,不允許重復(fù)登錄!", vbCritical, "自測(cè)考試系統(tǒng)登錄"
Else
StudentNum = Trim(txtNum)
StudentCode = Trim(txtCode)
DoTest.Caption = "學(xué)號(hào):" & Trim(txtNum) & " 準(zhǔn)考證號(hào):" & Trim(txtCode)
'修改缺考記錄
strSQL = "update 學(xué)生信息 set 缺考=0 where 學(xué)號(hào)='" & StudentNum & "'"
objCn.Execute strSQL
Unload Me '關(guān)閉登錄窗口
DoTest.Show '顯示考試窗口
End If
End If
End With
Set objCn = Nothing
Set objStuLogInfo = Nothing
lblNews = ""
Exit Sub
DealError:
If Err.Number = -2147467259 Then
MsgBox "考試服務(wù)器IP地址錯(cuò)誤!", vbCritical, "自測(cè)考試系統(tǒng)登錄"
txtIP.SetFocus
txtIP.SelStart = 0
txtIP.SelLength = Len(txtIP)
Else
MsgBox "程序運(yùn)行出錯(cuò):" & Err.Description, vbCritical, "自測(cè)考試系統(tǒng)登錄"
End If
Set objCn = Nothing
Set objStuLogInfo = Nothing
lblNews = ""
End Sub
Private Sub Form_Load()
End Sub
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -