📄 frmdl.frm
字号:
VERSION 5.00
Begin VB.Form Frmdl
BorderStyle = 3 'Fixed Dialog
Caption = "考生登录"
ClientHeight = 3750
ClientLeft = 45
ClientTop = 330
ClientWidth = 3735
Icon = "Frmdl.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3750
ScaleWidth = 3735
ShowInTaskbar = 0 'False
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Cmdml
Caption = "正确无误"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 615
Left = 960
TabIndex = 6
Top = 2880
Width = 1695
End
Begin VB.TextBox Txtzwh
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 1080
TabIndex = 4
Top = 1800
Width = 1740
End
Begin VB.TextBox Txtname
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 1080
TabIndex = 5
Top = 1080
Width = 1740
End
Begin VB.TextBox Txtcode
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 1080
MaxLength = 8
TabIndex = 3
Top = 360
Width = 1740
End
Begin VB.Label Lblsm
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000FF&
Height = 375
Left = 240
TabIndex = 7
Top = 2280
Width = 3255
End
Begin VB.Label Label3
Caption = "座位号"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 360
TabIndex = 2
Top = 1920
Width = 975
End
Begin VB.Label Label2
Caption = "学 号"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 360
TabIndex = 1
Top = 480
Width = 975
End
Begin VB.Label Label1
Caption = "姓 名"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 360
TabIndex = 0
Top = 1200
Width = 975
End
End
Attribute VB_Name = "Frmdl"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdml_Click()
If Len(Txtcode.Text) < 8 Then
Lblsm.Caption = "准考证号必须输入,长度为8位"
Txtcode.SetFocus
ElseIf Len(Txtname.Text) = 0 Then
Lblsm.Caption = "考生姓名必须输入"
Txtname.SetFocus
Exit Sub
ElseIf Len(Txtzwh.Text) = 0 Then
Lblsm.Caption = "座位号必须输入"
Txtzwh.SetFocus
Exit Sub
End If
Lblsm.Caption = ""
'----------------------------------------------------------
' 向UserDb库添加一条用户记录
'----------------------------------------------------------
Set rsuser = db.OpenRecordset("UserDb")
With rsuser
.Index = "PrimaryKey"
.Seek "=", Trim(Txtcode.Text)
If .NoMatch Then
.AddNew
.Fields("user_id").Value = Txtcode.Text
.Fields("user_name").Value = Txtname.Text
.Fields("user_seat").Value = Txtzwh.Text
Else
If .Fields("user_flag").Value = True Then
MsgBox "该名同学已参加过考试,退出程序", 48
End
End If
End If
End With
Frmxz.Show '切换并显示Frmxz(考生答题)窗体
Unload Me '卸载Frmdl(考生登录)窗体
End Sub
Private Sub Form_Load()
On Error Resume Next
'-----------------------------------------------------------------------
' 通过DAO打开用户登录库UserDb
'-----------------------------------------------------------------------
Set db = DBEngine.Workspaces(0).OpenDatabase(App.Path & "\test.mdb", False, False)
CenterOnSetupForm Me '将屏幕放在中间显示
End Sub
Private Sub Txtcode_LostFocus()
'-----------------------------------------------------------------------
' 检查准考证号必须输入8位的数字
'-----------------------------------------------------------------------
If Len(Txtcode.Text) < 8 Then
Lblsm.Caption = "准考证号必须输入,长度为8位!"
Txtcode.SetFocus
ElseIf Not IsNumeric(Txtcode.Text) Then
Lblsm.Caption = "准考证号必须是数字!"
Txtcode.SetFocus
Else
Lblsm.Caption = ""
Txtname.SetFocus
End If
End Sub
Private Sub Txtname_LostFocus()
'-----------------------------------------------------------------------
' 检查必须输入考生姓名
'-----------------------------------------------------------------------
If Len(Txtcode.Text) < 8 Or Not IsNumeric(Txtcode.Text) Then
Txtcode.SetFocus
ElseIf Len(Txtname.Text) = 0 Then
Lblsm.Caption = "考生姓名必须输入!"
Txtname.SetFocus
Else
Lblsm.Caption = ""
Txtzwh.SetFocus
End If
End Sub
Private Sub Txtzwh_LostFocus()
'-----------------------------------------------------------------------
' 检查必须输入座位号,且座位号为数字
'-----------------------------------------------------------------------
If Len(Txtname.Text) = 0 Then
Txtname.SetFocus
ElseIf Len(Txtzwh.Text) = 0 Then
Lblsm.Caption = "座位号必须输入!"
Txtzwh.SetFocus
ElseIf Not IsNumeric(Txtzwh.Text) Then
Lblsm.Caption = "座位号必须是数字"
Txtzwh.SetFocus
Else
Lblsm.Caption = ""
Cmdml.SetFocus
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -