📄 form5.frm
字号:
VERSION 5.00
Begin VB.Form Form5
Caption = "Form5"
ClientHeight = 3660
ClientLeft = 60
ClientTop = 345
ClientWidth = 5325
LinkTopic = "Form5"
ScaleHeight = 3660
ScaleWidth = 5325
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command2
Caption = "关闭"
Height = 375
Left = 1800
TabIndex = 10
Top = 2520
Width = 855
End
Begin VB.CommandButton Command1
Caption = "增加"
Height = 375
Left = 600
TabIndex = 9
Top = 2520
Width = 855
End
Begin VB.TextBox Text1
Height = 270
Left = 960
TabIndex = 8
Text = "0"
Top = 2040
Width = 1215
End
Begin VB.Frame Frame1
Caption = "增加学生成绩"
Height = 3375
Left = 120
TabIndex = 0
Top = 120
Width = 5055
Begin VB.ComboBox Combo3
Height = 300
Left = 840
TabIndex = 5
Text = "Combo3"
Top = 1440
Width = 1215
End
Begin VB.ComboBox Combo2
Height = 300
ItemData = "Form5.frx":0000
Left = 840
List = "Form5.frx":0002
TabIndex = 4
Text = "Combo2"
Top = 960
Width = 1215
End
Begin VB.ComboBox Combo1
Height = 300
Left = 840
TabIndex = 2
Text = "选择班级"
Top = 480
Width = 1215
End
Begin VB.Label Label4
Caption = "成绩"
Height = 375
Left = 240
TabIndex = 7
Top = 1920
Width = 495
End
Begin VB.Label Label3
Caption = "科目"
Height = 255
Left = 240
TabIndex = 6
Top = 1440
Width = 495
End
Begin VB.Label Label2
Caption = "学号"
Height = 255
Left = 240
TabIndex = 3
Top = 960
Width = 495
End
Begin VB.Label Label1
Caption = "班级"
Height = 255
Left = 240
TabIndex = 1
Top = 480
Width = 375
End
End
End
Attribute VB_Name = "Form5"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public conn As New ADODB.Connection
Public rs As New ADODB.Recordset
Private Sub Combo1_Click()
'这个班级的学生学号
Combo2.Clear
Dim sql As String
sql = "select 学号 from 学生基本信息 where 班级 = '" & Combo1.Text & "'"
rs.Open sql, conn
Do While Not rs.EOF
Combo2.AddItem (rs("学号"))
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
'这个班级学生的科目
sql = "select * from 成绩科目 where 班级ID = '" & Combo1.Text & "'"
rs.Open sql, conn
Do While Not rs.EOF
Combo3.AddItem (rs("成绩科目"))
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
End Sub
Private Sub Command1_Click()
If Text1.Text = "" Then
MsgBox "成绩不能为空"
Else
conn.Execute "insert into 学生成绩(成绩,学生ID,班级ID,科目ID) values(" & Text1.Text & ",'" & Combo2.Text & "','" & Combo1.Text & "','" & Combo3.Text & "')"
MsgBox "成绩已经添加"
Text1.Text = 0
End If
End Sub
Private Sub Command2_Click()
Me.Hide
End Sub
Private Sub Form_Load()
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + App.Path + "\student.mdb;Persist Security Info=False"
conn.Open
rs.Open "select * from 班级", conn
Do While Not rs.EOF
Combo1.AddItem (rs("班级"))
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -