📄 添加班级信息.frm
字号:
VERSION 5.00
Begin VB.Form 添加班级信息
Caption = "Form1"
ClientHeight = 4395
ClientLeft = 60
ClientTop = 345
ClientWidth = 6210
LinkTopic = "Form1"
ScaleHeight = 4395
ScaleWidth = 6210
StartUpPosition = 3 '窗口缺省
Begin VB.Frame Frame1
Caption = "Frame1"
Height = 3855
Left = 3960
TabIndex = 8
Top = 360
Width = 2055
Begin VB.TextBox Text3
Height = 2895
Left = 240
TabIndex = 9
Text = " "
Top = 480
Width = 1575
End
End
Begin VB.ComboBox Combo1
Height = 300
Left = 1800
TabIndex = 7
Text = " "
Top = 2280
Width = 2055
End
Begin VB.CommandButton Command2
Caption = "取消"
Height = 615
Left = 2160
TabIndex = 6
Top = 3240
Width = 1335
End
Begin VB.CommandButton Command1
Caption = "添加"
Height = 615
Left = 240
TabIndex = 5
Top = 3240
Width = 1335
End
Begin VB.TextBox Text2
Height = 615
Left = 2040
TabIndex = 4
Text = " "
Top = 1320
Width = 1335
End
Begin VB.TextBox Text1
Height = 615
Left = 2040
TabIndex = 3
Text = " "
Top = 240
Width = 1335
End
Begin VB.Label Label3
Caption = "班级名称"
Height = 615
Left = 360
TabIndex = 2
Top = 1200
Width = 1335
End
Begin VB.Label Label2
Caption = "系部编号"
Height = 615
Left = 240
TabIndex = 1
Top = 2160
Width = 1335
End
Begin VB.Label Label1
Caption = "班级编号"
Height = 615
Left = 360
TabIndex = 0
Top = 240
Width = 1335
End
End
Attribute VB_Name = "添加班级信息"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim rs12 As New Recordset
Private Sub Combo1_Click()
Dim rs13 As New ADODB.Recordset
rs13.Open "select * from 系部表 where 系部编号='" + Trim(Combo1.Text) + "'", cnn, 3, 1
If Not rs13.EOF Then
Text3 = rs13("系部编号") + rs13("系部名称")
End If
End Sub
Private Sub Command1_Click()
rs12.AddNew
rs12("班级编号") = Trim(Text1)
rs12("班级名称") = Trim(Text2)
rs12("系部编号") = Trim(Combo1.Text)
rs12.Update
rs12.Requery
MsgBox "添加成功!"
End Sub
Private Sub Command2_Click()
Me.Hide
End Sub
Private Sub Form_Load()
Dim rs13 As New Recordset
rs13.Open "select * from 系部表", cnn, 3, 1
Do While Not rs13.EOF
Combo1.AddItem rs13("系部编号")
rs13.MoveNext
Loop
rs13.Close
If rs12.State <> 0 Then rs12.Close
rs12.Open "select * from 班级表", cnn, 3, 3
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
rs12.Find "班级编号='" + Trim(Text1) + "'"
If Not rs12.EOF() Then
Text2 = rs12("班级名称")
Combo1.Text = rs12("系部编号")
End If
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -