📄 form1.frm
字号:
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 960
TabIndex = 1
Text = "TxtSno"
Top = 120
Width = 1455
End
Begin MSAdodcLib.Adodc AdodcStudent
Height = 375
Left = 1560
Top = 3480
Visible = 0 'False
Width = 2415
_ExtentX = 4260
_ExtentY = 661
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 2
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=学生管理数据库;Data Source=(local)"
OLEDBString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=学生管理数据库;Data Source=(local)"
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = "sa"
Password = ""
RecordSource = "Student"
Caption = "AdodcStudent"
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.Label Label5
Caption = "所在系"
BeginProperty Font
Name = "楷体_GB2312"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 375
Left = 2760
TabIndex = 7
Top = 840
Width = 975
End
Begin VB.Label Label4
Caption = "年龄"
BeginProperty Font
Name = "楷体_GB2312"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 375
Left = 3000
TabIndex = 6
Top = 240
Width = 735
End
Begin VB.Label Label3
Caption = "性别"
BeginProperty Font
Name = "楷体_GB2312"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 375
Left = 240
TabIndex = 3
Top = 1440
Width = 735
End
Begin VB.Label Label2
Caption = "姓名"
BeginProperty Font
Name = "楷体_GB2312"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 375
Left = 240
TabIndex = 2
Top = 840
Width = 735
End
Begin VB.Label Label1
Caption = "学号"
BeginProperty Font
Name = "楷体_GB2312"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 375
Left = 240
TabIndex = 0
Top = 240
Width = 735
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub CmdAdd_Click() ' “添加”命令按钮
AdodcStudent.Recordset.AddNew
'使“添加”和“删除”按钮为不可用状态
CmdAdd.Enabled = False
CmdDel.Enabled = False
'使“更改”和“取消”按钮为可用状态
CmdUpdate.Enabled = True
CmdCancel.Enabled = True
End Sub
Private Sub CmdCancel_Click() ' “取消”命令按钮
AdodcStudent.Recordset.CancelUpdate
'使“添加”和“删除”按钮为可用状态
CmdAdd.Enabled = True
CmdDel.Enabled = True
'使“取消”按钮为不可用状态
CmdCancel.Enabled = False
End Sub
Private Sub CmdDel_Click() ' “删除”命令按钮
Dim res As Integer
res = MsgBox("确实要删除此行记录吗?", _
vbExclamation + vbYesNo + vbDefaultButton2) '提示用户
If res = vbYes Then '如果确实要删除
AdodcStudent.Recordset.Delete
AdodcStudent.Recordset.MoveNext
If AdodcStudent.Recordset.EOF = True Then
AdodcStudent.Recordset.MoveLast
End If
End If
End Sub
Private Sub CmdExit_Click() ' “退出”命令按钮
End
End Sub
Private Sub CmdFirst_Click() ' “第一条”命令按钮
AdodcStudent.Recordset.MoveFirst
End Sub
Private Sub CmdLast_Click() ' “末一条”命令按钮
AdodcStudent.Recordset.MoveLast
End Sub
Private Sub CmdNext_Click() ' “下一条”命令按钮
AdodcStudent.Recordset.MoveNext
If AdodcStudent.Recordset.EOF = True Then
'如果已经移到了最后一行之后,则将指针定位在最后一行
AdodcStudent.Recordset.MoveLast
End If
End Sub
Private Sub CmdPrevious_Click() ' “上一条”命令按钮
AdodcStudent.Recordset.MovePrevious
If AdodcStudent.Recordset.BOF = True Then
'如果已经移到了第一行之前,则将指针定位在第一行
AdodcStudent.Recordset.MoveFirst
End If
End Sub
Private Sub CmdUpdate_Click() ' “更新”命令按钮
'将文本框中的当前值写入结果集相应字段中
AdodcStudent.Recordset.Fields("Sno") = Trim(TxtSno.Text)
AdodcStudent.Recordset.Fields("Sname") = Trim(TxtSname.Text)
AdodcStudent.Recordset.Fields("Ssex") = Trim(TxtSsex.Text)
AdodcStudent.Recordset.Fields("Sage") = CInt(Trim(TxtSage.Text))
AdodcStudent.Recordset.Fields("Sdept") = Trim(TxtSdept.Text)
'使更新生效
AdodcStudent.Recordset.Update
'使“添加”和“删除”按钮为可用状态
CmdAdd.Enabled = True
CmdDel.Enabled = True
'使“取消”按钮为不可用状态
CmdCancel.Enabled = False
End Sub
Private Sub Form_Load()
'初始时使“取消”按钮为不可用状态
CmdCancel.Enabled = False
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -