📄 虚拟班级窗口.frm
字号:
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00C00000&
Height = 735
Left = 240
TabIndex = 21
Top = 3120
Width = 3975
End
Begin VB.Label Label4
BackStyle = 0 'Transparent
Caption = "人 数:"
BeginProperty Font
Name = "华文行楷"
Size = 36
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00C00000&
Height = 735
Left = 240
TabIndex = 20
Top = 4320
Width = 3855
End
Begin VB.Label Label3
BackStyle = 0 'Transparent
Caption = "专业编号:"
BeginProperty Font
Name = "华文行楷"
Size = 36
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00C00000&
Height = 735
Left = 240
TabIndex = 19
Top = 840
Width = 4095
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "班级编号:"
BeginProperty Font
Name = "华文行楷"
Size = 36
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00C00000&
Height = 735
Left = 240
TabIndex = 18
Top = 2040
Width = 3735
End
End
Begin VB.Frame Frame3
BackColor = &H00FFC0C0&
Height = 1575
Left = 360
TabIndex = 6
Top = 7080
Width = 14655
Begin VB.CommandButton Command1
Caption = "添加"
BeginProperty Font
Name = "隶书"
Size = 26.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 750
Left = 360
TabIndex = 23
Top = 360
Width = 1575
End
Begin VB.CommandButton Cmdadd
BackColor = &H00FFC0C0&
Caption = "保存"
BeginProperty Font
Name = "隶书"
Size = 26.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 750
Left = 2832
TabIndex = 11
Top = 360
Width = 1575
End
Begin VB.CommandButton Cmdexit
BackColor = &H00FFC0C0&
Caption = "退出"
BeginProperty Font
Name = "隶书"
Size = 26.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 750
Left = 12720
TabIndex = 10
Top = 360
Width = 1575
End
Begin VB.CommandButton Cmdmodify
BackColor = &H00FFC0C0&
Caption = "编辑"
BeginProperty Font
Name = "隶书"
Size = 26.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 750
Left = 5304
TabIndex = 9
Top = 360
Width = 1575
End
Begin VB.CommandButton cmdfind
BackColor = &H00FFC0C0&
Caption = "查找"
BeginProperty Font
Name = "隶书"
Size = 26.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 750
Left = 7776
TabIndex = 8
Top = 360
Width = 1575
End
Begin VB.CommandButton Cmddelete
BackColor = &H00FFC0C0&
Caption = "删除"
BeginProperty Font
Name = "隶书"
Size = 26.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 750
Left = 10248
TabIndex = 7
Top = 360
Width = 1575
End
End
Begin VB.Frame Frame2
BackColor = &H00FFC0C0&
Caption = "班级编号说明:"
BeginProperty Font
Name = "隶书"
Size = 36
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00C00000&
Height = 1815
Left = 360
TabIndex = 0
Top = 8760
Width = 14655
Begin VB.Label Label7
BackStyle = 0 'Transparent
Caption = "班级编号规则为专业在年级中的编号+班级号。"
BeginProperty Font
Name = "楷体_GB2312"
Size = 26.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00C00000&
Height = 855
Left = 120
TabIndex = 5
Top = 840
Width = 13935
End
End
End
Attribute VB_Name = "Frmclass"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim temp As DAO.Recordset
Dim db As DAO.Database
Dim rst As DAO.Recordset
Private Sub Cmddelete_Click()
Set rst = db.OpenRecordset("select * from class")
rst.Filter = "classid='" & Txtclassid.Text & "'"
Set rst = rst.OpenRecordset()
rst.Delete
Set rst = db.OpenRecordset("select * from class")
If rst.RecordCount() <> 0 Then
If rst.EOF = True Then
rst.MoveFirst
Else
rst.MoveNext
End If
filltext
Else
clearfield
MsgBox "数据库中已经没有记录了!"
hidebutton
End If
adodclass.Refresh
End Sub
Private Sub Cmdexit_Click()
db.Close
Unload Me
frmmain.Show vbModal
End Sub
Private Sub cmdfirst_Click()
rst.MoveFirst
filltext
End Sub
Private Sub Cmdlast_Click()
rst.MoveLast
filltext
End Sub
Private Sub Cmdmodify_Click()
Set temp = db.OpenRecordset("select * from class")
temp.Filter = "classid='" & Txtclassid.Text & "'"
Set temp = temp.OpenRecordset()
If temp.RecordCount = 0 Then
MsgBox ("这个专业方向编号不存在,编辑操作失败!")
temp.Close
Exit Sub
End If
temp.Close
rst.edit
fillrecord
rst.Update
adodclass.Refresh
Txtmajorid.SetFocus
End Sub
Private Sub Cmdnext_Click()
rst.MoveNext
If rst.EOF Then
MsgBox "这是最后一个记录了!"
rst.MoveLast
End If
filltext
End Sub
Private Sub Cmdprevious_Click()
rst.MovePrevious
If rst.BOF Then
MsgBox "这是第一个记录了!"
rst.MoveFirst
End If
filltext
End Sub
Private Sub Cmdadd_Click()
Set temp = db.OpenRecordset("select * from class")
temp.Filter = "classid='" & Txtclassid.Text & "'"
Set temp = temp.OpenRecordset()
If temp.RecordCount <> 0 Then
MsgBox ("这个班级编号已存在,您输入的信息不能被保存!")
Exit Sub
End If
temp.Close
If rst.RecordCount() <> 0 Then
rst.MoveLast
End If
rst.AddNew
fillrecord
rst.Update
clearfield
Txtmajorid.SetFocus
adodclass.Refresh
End Sub
Private Sub Command1_Click()
clearfield
Txtmajorid.SetFocus
End Sub
Private Sub Dgdclass_Click()
Txtclassid.Text = Dgdclass.Columns(1).Text
Txtclassname.Text = Dgdclass.Columns(2).Text
Txtnumber.Text = Dgdclass.Columns(3).Text
End Sub
Private Sub Dgdmajor_Click()
Txtmajorid.Text = Dgdmajor.Text
End Sub
Private Sub Dgdmajor_GotFocus()
Dgdclass.Visible = False
End Sub
Public Sub filltext()
Txtmajorid.Text = rst.Fields("majorid")
Txtclassid.Text = rst.Fields("classid")
Txtclassname.Text = rst.Fields("classname")
Txtnumber.Text = rst.Fields("number")
End Sub
Public Sub clearfield()
Txtmajorid.Text = ""
Txtclassid.Text = ""
Txtclassname.Text = ""
Txtnumber.Text = ""
End Sub
Private Sub Form_Load()
Set db = DBEngine.Workspaces(0).OpenDatabase("d:\basic.mdb")
Set rst = db.OpenRecordset("select * from class")
If rst.RecordCount() = 0 Then
'clearfield
hidebutton
Else
showbutton
'rst.MoveFirst
'filltext
End If
clearfield
Dgdclass.Visible = False
End Sub
Public Sub hidebutton()
Cmddelete.Enabled = False
Cmdnext.Enabled = False
cmdfirst.Enabled = False
Cmdlast.Enabled = False
Cmdmodify.Enabled = False
Cmdprevious.Enabled = False
End Sub
Public Sub showbutton()
Cmddelete.Enabled = True
Cmdnext.Enabled = True
cmdfirst.Enabled = True
Cmdlast.Enabled = True
Cmdmodify.Enabled = True
Cmdprevious.Enabled = True
End Sub
Public Sub fillrecord()
rst.Fields("majorid") = Txtmajorid.Text
rst.Fields("classid") = Txtclassid.Text
rst.Fields("classname") = Txtclassname.Text
rst.Fields("number") = Txtnumber.Text
End Sub
Private Sub Txtclassid_Click()
adodclass.Refresh
End Sub
Private Sub Txtclassid_GotFocus()
adodclass.Refresh
Dgdmajor.Visible = False
Dgdclass.Visible = True
End Sub
Private Sub txtmajorid_Change()
adodclass.RecordSource = "select majorid,classid,classname,number from class where majorid='" & Txtmajorid.Text & "'"
adodclass.Refresh
End Sub
Private Sub Txtmajorid_GotFocus()
Dgdmajor.Visible = True
Dgdclass.Visible = False
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -