📄 frmaddess.frm
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form frmAddEss
Caption = "添加学籍信息"
ClientHeight = 5265
ClientLeft = 60
ClientTop = 345
ClientWidth = 7065
LinkTopic = "Form1"
ScaleHeight = 5265
ScaleWidth = 7065
StartUpPosition = 3 '窗口缺省
Begin MSAdodcLib.Adodc adoadd
Height = 375
Left = 5040
Top = 4680
Visible = 0 'False
Width = 1815
_ExtentX = 3201
_ExtentY = 661
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 8
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=student.mdb;Persist Security Info=False"
OLEDBString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=student.mdb;Persist Security Info=False"
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = ""
Caption = "Adodc1"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin VB.CommandButton Command2
Caption = "退出"
BeginProperty Font
Name = "隶书"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 5040
TabIndex = 11
Top = 3000
Width = 1815
End
Begin VB.CommandButton Command1
Caption = "确认添加"
BeginProperty Font
Name = "隶书"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 5040
TabIndex = 10
Top = 840
Width = 1815
End
Begin VB.ComboBox cboclass
Height = 300
Left = 2160
TabIndex = 9
Top = 4200
Width = 2295
End
Begin VB.ComboBox cbosex
Height = 300
ItemData = "frmAddEss.frx":0000
Left = 2160
List = "frmAddEss.frx":000A
TabIndex = 8
Top = 2400
Width = 2295
End
Begin VB.TextBox txtborn
Height = 375
Left = 2160
TabIndex = 7
Top = 3240
Width = 2295
End
Begin VB.TextBox txtname
Height = 375
Left = 2160
TabIndex = 6
Top = 1560
Width = 2295
End
Begin VB.TextBox txtsid
Height = 375
Left = 2160
TabIndex = 5
Top = 720
Width = 2295
End
Begin VB.Label Label5
Caption = "班 级"
BeginProperty Font
Name = "隶书"
Size = 18
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 240
TabIndex = 4
Top = 4080
Width = 1455
End
Begin VB.Label Label4
Caption = "出生日期"
BeginProperty Font
Name = "隶书"
Size = 18
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 240
TabIndex = 3
Top = 3240
Width = 1455
End
Begin VB.Label Label3
Caption = "性 别"
BeginProperty Font
Name = "隶书"
Size = 18
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 240
TabIndex = 2
Top = 2400
Width = 1455
End
Begin VB.Label Label2
Caption = "姓 名"
BeginProperty Font
Name = "隶书"
Size = 18
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 240
TabIndex = 1
Top = 1560
Width = 1455
End
Begin VB.Label Label1
Caption = "学 号"
BeginProperty Font
Name = "隶书"
Size = 18
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 240
TabIndex = 0
Top = 720
Width = 1455
End
End
Attribute VB_Name = "frmAddEss"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub cboclass_LostFocus()
Call newclassitem(cboclass)
End Sub
Private Sub Command1_Click()
'各文本框若为空白,提示重新输入
If Trim$(txtsid.Text) = "" Then
MsgBox "请输入学号!", vbExclamation
txtsid.SetFocus
Exit Sub
End If
If Trim$(txtname.Text) = "" Then
MsgBox "请输入姓名!", vbExclamation
txtname.SetFocus
Exit Sub
End If
If Trim$(txtborn.Text) = "" Then
MsgBox "请输入出生日期!", vbExclamation
txtborn.SetFocus
Exit Sub
End If
If Trim$(cboclass.Text) = "" Then
MsgBox "请选择或输入班级!", vbExclamation
cboclass.SetFocus
Exit Sub
End If
adoadd.Refresh
'检查是否有重复学号
adoadd.Recordset.Find ("学号='" & txtsid.Text & "'")
If Not adoadd.Recordset.EOF Then
MsgBox "学号重复,请重新输入!", vbExclamation
Call focusback(txtsid) '焦点返回学号框
Exit Sub
End If
If Not IsDate(txtborn.Text) Then
MsgBox "出生日期应按日期格式(yyyy-mm-dd)输入!", vbExclamation
Call focusback(txtborn) '焦点返回学号框
Exit Sub
Else
txtborn.Text = Format(txtborn.Text, "yyyy-mm-dd")
With adoadd.Recordset
.AddNew
.Fields(0) = Trim$(txtsid.Text)
.Fields(1) = Trim$(txtname.Text)
.Fields(2) = Trim$(cbosex.Text)
.Fields(3) = Trim$(txtborn.Text)
.Fields(4) = Trim$(cboclass.Text)
.Update
End With
MsgBox "学籍信息已成功添加!", vbInformation
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Dim sql As String
sql = "select * from 学籍"
adoadd.RecordSource = sql
adoadd.Refresh
Call addclassitem(cboclass)
End Sub
Private Sub Form_Unload(Cancel As Integer)
frmMain.Show
End Sub
Private Sub txtsid_KeyPress(KeyAscii As Integer)
'按键非数字或回删键,取消
If Not IsNumeric(Chr(KeyAscii)) And KeyAscii <> 8 Then
KeyAscii = 0
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -