📄 frminputstu.frm
字号:
VERSION 5.00
Begin VB.Form frmInputStu
BorderStyle = 1 'Fixed Single
Caption = "输入考生信息"
ClientHeight = 7650
ClientLeft = 45
ClientTop = 330
ClientWidth = 10275
LinkTopic = "Form1"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 7650
ScaleWidth = 10275
Begin VB.CommandButton cmdClose
Caption = "关 闭"
Height = 855
Left = 5520
TabIndex = 37
Top = 3240
Width = 1575
End
Begin VB.CommandButton cmdReset
Caption = "取消重填"
Height = 855
Left = 3000
TabIndex = 34
Top = 3240
Width = 1695
End
Begin VB.CommandButton cmdAdd
Caption = "添加入考生表"
Height = 855
Left = 720
TabIndex = 17
Top = 3240
Width = 1455
End
Begin VB.Frame Frame2
Caption = "考生成绩"
Height = 1335
Left = 120
TabIndex = 26
Top = 1560
Width = 9135
Begin VB.TextBox Text8
Height = 285
Index = 4
Left = 1080
TabIndex = 13
Top = 840
Width = 975
End
Begin VB.ComboBox Combo3
Height = 315
ItemData = "frmInputStu.frx":0000
Left = 7800
List = "frmInputStu.frx":000A
Style = 2 'Dropdown List
TabIndex = 16
Top = 840
Width = 975
End
Begin VB.ComboBox Combo2
Height = 315
ItemData = "frmInputStu.frx":001A
Left = 5640
List = "frmInputStu.frx":002A
Style = 2 'Dropdown List
TabIndex = 15
Top = 840
Width = 975
End
Begin VB.TextBox Text8
Height = 285
Index = 5
Left = 3360
TabIndex = 14
Top = 840
Width = 975
End
Begin VB.TextBox Text8
Height = 285
Index = 3
Left = 7800
TabIndex = 12
Top = 360
Width = 975
End
Begin VB.TextBox Text8
Height = 285
Index = 2
Left = 5640
TabIndex = 11
Top = 360
Width = 975
End
Begin VB.TextBox Text8
Height = 285
Index = 1
Left = 3360
TabIndex = 10
Top = 360
Width = 975
End
Begin VB.TextBox Text8
Height = 285
Index = 0
Left = 1080
TabIndex = 9
Top = 360
Width = 975
End
Begin VB.Label Label9
Caption = "特殊加分"
Height = 255
Index = 8
Left = 240
TabIndex = 36
Top = 840
Width = 735
End
Begin VB.Label Label9
Caption = "文理科类型"
Height = 255
Index = 7
Left = 6720
TabIndex = 35
Top = 840
Width = 1095
End
Begin VB.Label Label9
Caption = "外语语种"
Height = 255
Index = 6
Left = 4680
TabIndex = 33
Top = 840
Width = 855
End
Begin VB.Label Label9
Caption = "总分"
Height = 255
Index = 5
Left = 2520
TabIndex = 32
Top = 840
Width = 495
End
Begin VB.Label Label9
Caption = "X 综合"
Height = 255
Index = 4
Left = 6960
TabIndex = 31
Top = 360
Width = 735
End
Begin VB.Label Label9
Caption = "外语"
Height = 255
Index = 2
Left = 4800
TabIndex = 29
Top = 360
Width = 495
End
Begin VB.Label Label9
Caption = "数学"
Height = 255
Index = 1
Left = 2520
TabIndex = 28
Top = 360
Width = 495
End
Begin VB.Label Label9
Caption = "语文"
Height = 255
Index = 0
Left = 360
TabIndex = 27
Top = 360
Width = 495
End
End
Begin VB.Frame Frame1
Caption = "考生基本信息"
Height = 1455
Left = 120
TabIndex = 1
Top = 0
Width = 9135
Begin VB.TextBox Text1
Height = 285
Index = 6
Left = 7560
TabIndex = 8
Top = 840
Width = 1335
End
Begin VB.TextBox Text1
Height = 285
Index = 5
Left = 5520
TabIndex = 7
Top = 840
Width = 735
End
Begin VB.TextBox Text1
Height = 285
Index = 4
Left = 3360
TabIndex = 6
Top = 840
Width = 1335
End
Begin VB.TextBox Text1
Height = 285
Index = 3
Left = 1200
TabIndex = 5
Top = 840
Width = 1335
End
Begin VB.TextBox Text1
Height = 285
Index = 2
Left = 7560
TabIndex = 4
Top = 360
Width = 1335
End
Begin VB.TextBox Text1
Height = 285
Index = 1
Left = 3360
TabIndex = 2
Top = 360
Width = 1335
End
Begin VB.ComboBox Combo1
Height = 315
ItemData = "frmInputStu.frx":0046
Left = 5520
List = "frmInputStu.frx":0050
Style = 2 'Dropdown List
TabIndex = 3
Top = 360
Width = 735
End
Begin VB.TextBox Text1
Height = 285
Index = 0
Left = 1200
TabIndex = 0
Top = 360
Width = 1335
End
Begin VB.Label Label8
Caption = "出生年月日"
Height = 255
Left = 6480
TabIndex = 25
Top = 840
Width = 1095
End
Begin VB.Label Label7
Caption = "年龄"
Height = 255
Left = 4920
TabIndex = 24
Top = 840
Width = 735
End
Begin VB.Label Label6
Caption = "籍贯"
Height = 255
Left = 2760
TabIndex = 23
Top = 840
Width = 615
End
Begin VB.Label Label5
Caption = "政治面貌"
Height = 255
Left = 360
TabIndex = 22
Top = 840
Width = 735
End
Begin VB.Label Label4
Caption = "户口所在地"
Height = 255
Left = 6480
TabIndex = 21
Top = 360
Width = 975
End
Begin VB.Label Label3
Caption = "性别"
Height = 255
Left = 4920
TabIndex = 20
Top = 360
Width = 735
End
Begin VB.Label Label2
Caption = "姓名"
Height = 255
Left = 2760
TabIndex = 19
Top = 360
Width = 615
End
Begin VB.Label Label1
Caption = "准考证号"
Height = 255
Left = 360
TabIndex = 18
Top = 360
Width = 855
End
End
Begin VB.Label Label9
Caption = "Label9"
Height = 255
Index = 3
Left = 6240
TabIndex = 30
Top = 1920
Width = 495
End
End
Attribute VB_Name = "frmInputStu"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'定义6个窗体范围内的ADODB.Recordset变量
Dim rs_Stu As New ADODB.Recordset
Dim rs_Grade As New ADODB.Recordset
Dim rs_check As New ADODB.Recordset '用于检测添加记录时是否有重复的准考证号
Private Sub cmdAdd_Click()
'先检测是否添了一些必要信息
Dim i As Integer
Dim j As Integer
'检测准考证号是否为数字,因为此项为主码,应填写正确
If IsNumeric(Text1(0).Text) = False Then
MsgBox "准考证号应该为数字!", vbOKOnly + vbInformation, "注意"
Exit Sub
End If
For i = 0 To 6
If Text1(i).Text = "" Then
MsgBox "考生基本信息不可为空!", vbOKOnly + vbInformation, "注意"
Exit Sub
End If
Next i
'检测年龄是否为数字
If IsNumeric(Text1(5).Text) = False Then
MsgBox "年龄必须为数字!", vbOKOnly + vbInformation, "注意"
Exit Sub
End If
'检测日期书写是否正确
If IsDate(Text1(6).Text) = False Then
MsgBox "出生日期书写不对,应为2000-1-1这样的格式!", vbOKOnly + vbInformation, "注意"
Exit Sub
End If
'检测考生成绩是否已输入并且是否为数字
For i = 0 To 3
If Text8(i).Text = "" Then
MsgBox "考生分数信息不可为空!", vbOKOnly + vbInformation, "注意"
Exit Sub
End If
If IsNumeric(Text8(i).Text) = False Then
MsgBox "考生分数应为数字!", vbOKOnly + vbInformation, "注意"
Exit Sub
End If
Next i
Dim sum As Integer
sum = 0
For i = 0 To 4
sum = sum + Val(Text8(i).Text)
Next i
'总分等于各科分数之和
Text8(5).Text = sum
'检测输入的准考证号是否已存在,如果存在则提示用户输入另一个
Dim sqlCheck As String
sqlCheck = "select * from 考生基本信息表 where 准考证号= " & Val(Text1(0).Text)
rs_check.Open sqlCheck, conn, adOpenStatic, adLockOptimistic
If Not rs_check.EOF Then
MsgBox "该准考证号已经存在,请重填一个!", vbOKOnly + vbInformation, "注意"
rs_check.Close
Exit Sub
End If
rs_check.Close
'把用户输入信息添加入各表
rs_Stu.AddNew
rs_Stu.Fields(0) = Val(Text1(0).Text)
rs_Stu.Fields(1) = Text1(1).Text
rs_Stu.Fields(2) = Combo1.Text
For i = 2 To 4
rs_Stu.Fields(i + 1) = (Text1(i).Text)
Next i
rs_Stu.Fields(6) = Val(Text1(5).Text)
rs_Stu.Fields(7) = Text1(6).Text
rs_Stu.Update
'下面的加入成绩表为了简约代码,分成3部分完成
rs_Grade.AddNew
rs_Grade.Fields(0) = Val(Text1(0).Text)
rs_Grade.Fields(1) = Text1(1).Text '准考证号的姓名使用考生基本信息表中的
For i = 0 To 5
rs_Grade.Fields(i + 2) = Val(Text8(i).Text)
Next i
rs_Grade.Fields(8) = Combo2.Text
rs_Grade.Fields(9) = Combo3.Text
rs_Grade.Update
MsgBox "添加考生信息成功!", vbOKOnly + vbExclamation, "注意"
'置空所有textbox便于输入另一信息
For i = 0 To 6
Text1(i).Text = ""
Next i
For i = 0 To 4
Text8(i).Text = ""
Next i
End Sub
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub cmdReset_Click()
'置空所有textbox控件
For i = 0 To 6
Text1(i).Text = ""
Next i
For i = 0 To 4
Text8(i).Text = ""
Next i
End Sub
Private Sub Form_Load()
Dim X0 As Long
Dim Y0 As Long
'让窗体居中
X0 = Screen.Width
Y0 = Screen.Height
X0 = (X0 - Me.Width) / 2
Y0 = (Y0 - Me.Height) / 2
Me.Move X0, Y0
'先设置各个ComboBox的默认值
Combo1.ListIndex = 0
Combo2.ListIndex = 0
Combo3.ListIndex = 0
'设置总分一栏不可写
Text8(5).Enabled = False
Dim sql_Stu As String
Dim sql_Grade As String
Dim sql_Wish As String
Dim sql_Study As String
Dim sql_Relation As String
'在from_laod()方法中打开5个考生信息表
sql_Stu = "select * from 考生基本信息表"
rs_Stu.CursorLocation = adUseClient
rs_Stu.Open sql_Stu, conn, adOpenStatic, adLockOptimistic
sql_Grade = "select * from 考生成绩表"
rs_Grade.CursorLocation = adUseClient
rs_Grade.Open sql_Grade, conn, adOpenStatic, adLockOptimistic
End Sub
Private Sub Form_Unload(Cancel As Integer)
rs_Stu.Close
rs_Grade.Close
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -