📄 添加成绩信息.frm
字号:
VERSION 5.00
Begin VB.Form Form8
Caption = "添加成绩信息"
ClientHeight = 5115
ClientLeft = 60
ClientTop = 450
ClientWidth = 8115
LinkTopic = "Form8"
MDIChild = -1 'True
ScaleHeight = 5115
ScaleWidth = 8115
WindowState = 2 'Maximized
Begin VB.TextBox txtresult
BackColor = &H00E0E0E0&
Height = 375
Left = 4920
TabIndex = 8
Top = 2640
Width = 1815
End
Begin VB.TextBox txtname
BackColor = &H00E0E0E0&
Height = 375
Left = 4920
TabIndex = 7
Top = 1680
Width = 1815
End
Begin VB.ComboBox cbocourse
BackColor = &H00E0E0E0&
Height = 300
Left = 1560
TabIndex = 6
Top = 2640
Width = 1575
End
Begin VB.ComboBox cboid
BackColor = &H00E0E0E0&
Height = 300
Left = 1560
TabIndex = 5
Top = 1680
Width = 1575
End
Begin VB.ComboBox cboclass
BackColor = &H00E0E0E0&
Height = 300
Left = 4920
TabIndex = 4
Top = 720
Width = 1815
End
Begin VB.ComboBox cbotype
BackColor = &H00E0E0E0&
Height = 300
Left = 1560
TabIndex = 3
Top = 720
Width = 1575
End
Begin VB.CommandButton cmdclear
BackColor = &H00C0C0C0&
Caption = "清 空"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 5640
Style = 1 'Graphical
TabIndex = 2
Top = 4080
Width = 1575
End
Begin VB.CommandButton cmdexit
BackColor = &H00C0C0C0&
Caption = "退 出"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 3120
Style = 1 'Graphical
TabIndex = 1
Top = 4080
Width = 1575
End
Begin VB.CommandButton cmdok
BackColor = &H00C0C0C0&
Caption = "确 认"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 600
Picture = "添加成绩信息.frx":0000
Style = 1 'Graphical
TabIndex = 0
Top = 4080
Width = 1455
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "考试类型"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000FF&
Height = 495
Left = 240
TabIndex = 14
Top = 720
Width = 1095
End
Begin VB.Label Label3
BackStyle = 0 'Transparent
Caption = "选择学号"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000FF&
Height = 495
Left = 240
TabIndex = 13
Top = 1800
Width = 1215
End
Begin VB.Label Label5
BackStyle = 0 'Transparent
Caption = "选择课程"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000FF&
Height = 495
Left = 240
TabIndex = 12
Top = 2640
Width = 1215
End
Begin VB.Label Label6
BackStyle = 0 'Transparent
Caption = "输入分数"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000FF&
Height = 495
Left = 3720
TabIndex = 11
Top = 2640
Width = 1215
End
Begin VB.Label Label4
BackStyle = 0 'Transparent
Caption = "姓名"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000FF&
Height = 495
Left = 3720
TabIndex = 10
Top = 1680
Width = 855
End
Begin VB.Label Label2
BackStyle = 0 'Transparent
Caption = "班级"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000FF&
Height = 615
Left = 3720
TabIndex = 9
Top = 720
Width = 855
End
End
Attribute VB_Name = "Form8"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdclear_Click()
cbotype.Text = ""
cboid.Text = ""
cbocourse.Text = ""
cboclass.Text = ""
txtresult.Text = ""
txtname.Text = ""
End Sub
Private Sub cmdexit_Click()
Me.Hide
End Sub
Private Sub cmdOK_Click()
Dim txtsql As String
Dim mrc As Adodb.Recordset
Dim msgtext As String
If Trim(cbotype.Text) = "" Then
FrmMain.StatusBarmy.Panels.Item(1).Text = "请选择考试类型!"
cbotype.SetFocus
End If
If Trim(cboclass.Text) = "" Then
FrmMain.StatusBarmy.Panels.Item(1).Tag = "请选择班级!"
cboclass.Text = ""
cboclass.SetFocus
End If
If Trim(cboid.Text) = "" Then
FrmMain.StatusBarmy.Panels.Item(1).Text = "请选择学号!"
cboid.Text = ""
cboid.SetFocus
End If
If Trim(txtname.Text) = "" Then
FrmMain.StatusBarmy.Panels.Item(1).Text = "请输入姓名!"
txtname.Text = ""
txtname.SetFocus
End If
If Trim(cbocourse.Text) = "" Then
FrmMain.StatusBarmy.Panels.Item(1).Text = "请选择课程!"
cbocourse.Text = ""
cbocourse.SetFocus
End If
If Trim(txtresult.Text) = "" Then
FrmMain.StatusBarmy.Panels.Item(1).Text = "请输入分数!"
txtresult.Text = ""
txtresult.SetFocus
Else
txtsql = "select * from result_info"
Set mrc = executesql(txtsql, msgtext)
While (mrc.EOF = False)
If Trim(mrc.Fields(2) = Trim(cboid.Text)) Then
FrmMain.StatusBarmy.Panels.Item(1).Text = "该学号已存在,请重输!"
cbotype.SetFocus
cbotype.Text = ""
cboclass.Text = ""
cboid.Text = ""
txtname.Text = ""
cbocourse.Text = ""
txtresult.Text = ""
Exit Sub
Else
mrc.MoveNext
End If
Wend
End If
mrc.AddNew
mrc.Fields(5) = Trim(cbotype.Text)
mrc.Fields(2) = Trim(cboclass.Text)
mrc.Fields(0) = Trim(cboid.Text)
mrc.Fields(1) = Trim(txtname.Text)
mrc.Fields(3) = Trim(cbocourse.Text)
mrc.Fields(4) = Trim(txtresult.Text)
mrc.Update
mrc.Close
FrmMain.StatusBarmy.Panels.Item(1).Text = "成绩添加成功!"
End Sub
Private Sub Form_Load()
Dim mrc As Adodb.Recordset
Dim txtsql As String
Dim msgtext As String
Dim i As Integer
cbotype.AddItem ""
cbotype.AddItem "期中考试"
cbotype.AddItem "期末考试"
cbotype.AddItem "小测试"
txtsql = "select * from class_info"
Set mrc = executesql(txtsql, msgtext)
mrc.MoveFirst
cboclass.AddItem ""
For i = 1 To mrc.RecordCount
cboclass.AddItem mrc.Fields(0)
mrc.MoveNext
Next
mrc.Close
txtsql = "select * from student_info"
Set mrc = executesql(txtsql, msgtext)
mrc.MoveFirst
cboid.AddItem ""
For i = 1 To mrc.RecordCount
cboid.AddItem mrc.Fields(0)
mrc.MoveNext
Next
mrc.Close
txtsql = "select * from course_info"
Set mrc = executesql(txtsql, msgtext)
mrc.MoveFirst
cbocourse.AddItem ""
For i = 1 To mrc.RecordCount
cbocourse.AddItem mrc.Fields(2)
mrc.MoveNext
Next
mrc.Close
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -