📄 frmstat.frm
字号:
VERSION 5.00
Object = "{BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0"; "TABCTL32.OCX"
Begin VB.Form frmStat
BackColor = &H00C0C0C0&
BorderStyle = 3 'Fixed Dialog
Caption = "统计和用户管理"
ClientHeight = 5640
ClientLeft = 1860
ClientTop = 2010
ClientWidth = 6615
Icon = "frmStat.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 5640
ScaleWidth = 6615
ShowInTaskbar = 0 'False
Begin VB.CommandButton Command1
Caption = "关闭"
Default = -1 'True
Height = 375
Left = 5040
TabIndex = 0
Top = 5040
Width = 1335
End
Begin TabDlg.SSTab SSTab1
Height = 4815
Left = 0
TabIndex = 1
Top = 0
Width = 6375
_ExtentX = 11245
_ExtentY = 8493
_Version = 393216
Tabs = 4
Tab = 2
TabsPerRow = 4
TabHeight = 520
BackColor = 12632256
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "新宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
TabCaption(0) = "班级统计"
TabPicture(0) = "frmStat.frx":058A
Tab(0).ControlEnabled= 0 'False
Tab(0).Control(0)= "Label1"
Tab(0).Control(0).Enabled= 0 'False
Tab(0).Control(1)= "Text1"
Tab(0).Control(1).Enabled= 0 'False
Tab(0).Control(2)= "Combo1"
Tab(0).Control(2).Enabled= 0 'False
Tab(0).Control(3)= "Command2"
Tab(0).Control(3).Enabled= 0 'False
Tab(0).ControlCount= 4
TabCaption(1) = "学生成绩统计"
TabPicture(1) = "frmStat.frx":05A6
Tab(1).ControlEnabled= 0 'False
Tab(1).Control(0)= "Label2"
Tab(1).Control(0).Enabled= 0 'False
Tab(1).Control(1)= "Combo2"
Tab(1).Control(1).Enabled= 0 'False
Tab(1).Control(2)= "Command3"
Tab(1).Control(2).Enabled= 0 'False
Tab(1).Control(3)= "Text2"
Tab(1).Control(3).Enabled= 0 'False
Tab(1).ControlCount= 4
TabCaption(2) = "补考学生"
TabPicture(2) = "frmStat.frx":05C2
Tab(2).ControlEnabled= -1 'True
Tab(2).Control(0)= "Label3"
Tab(2).Control(0).Enabled= 0 'False
Tab(2).Control(1)= "Text3"
Tab(2).Control(1).Enabled= 0 'False
Tab(2).Control(2)= "Combo3"
Tab(2).Control(2).Enabled= 0 'False
Tab(2).Control(3)= "Command4"
Tab(2).Control(3).Enabled= 0 'False
Tab(2).ControlCount= 4
TabCaption(3) = "超级用户管理"
TabPicture(3) = "frmStat.frx":05DE
Tab(3).ControlEnabled= 0 'False
Tab(3).Control(0)= "Frame1"
Tab(3).ControlCount= 1
Begin VB.Frame Frame1
Caption = "管理"
Height = 3615
Left = -74760
TabIndex = 11
Top = 480
Width = 5895
Begin VB.ListBox List1
Height = 3480
Left = 0
TabIndex = 12
Top = 120
Width = 5895
End
End
Begin VB.CommandButton Command4
Caption = "&GO!"
Height = 300
Left = 3360
TabIndex = 10
Top = 640
Width = 975
End
Begin VB.ComboBox Combo3
Height = 300
Left = 1200
TabIndex = 9
Top = 640
Width = 2055
End
Begin VB.TextBox Text3
BackColor = &H8000000A&
Height = 3495
Left = 240
Locked = -1 'True
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 8
Top = 1080
Width = 5895
End
Begin VB.TextBox Text2
BackColor = &H8000000A&
Height = 3495
Left = -74760
Locked = -1 'True
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 7
Top = 1080
Width = 5895
End
Begin VB.CommandButton Command3
Caption = "&GO!"
Height = 300
Left = -71640
TabIndex = 6
Top = 640
Width = 975
End
Begin VB.ComboBox Combo2
Height = 300
Left = -73800
TabIndex = 5
Top = 640
Width = 2055
End
Begin VB.CommandButton Command2
Caption = "&GO!"
Height = 300
Left = -71640
TabIndex = 4
Top = 640
Width = 975
End
Begin VB.ComboBox Combo1
Height = 300
Left = -73800
TabIndex = 3
Top = 640
Width = 2055
End
Begin VB.TextBox Text1
BackColor = &H8000000A&
Height = 3495
Left = -74760
Locked = -1 'True
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 2
Top = 1080
Width = 5895
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "选择班号:"
Height = 180
Left = 240
TabIndex = 15
Top = 720
Width = 900
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "选择学号:"
Height = 180
Left = -74760
TabIndex = 14
Top = 720
Width = 900
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "选择班号:"
Height = 180
Left = -74760
TabIndex = 13
Top = 720
Width = 900
End
End
Begin VB.Line Line1
X1 = 0
X2 = 6360
Y1 = 4920
Y2 = 4920
End
Begin VB.Line Line2
BorderColor = &H00FFFFFF&
X1 = 0
X2 = 6360
Y1 = 4935
Y2 = 4935
End
End
Attribute VB_Name = "frmStat"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub Command1_Click()
Unload Me
End Sub
Private Sub Command2_Click()
If Combo1.ListIndex > -1 Then
Call Stat1(Combo1.Text)
End If
End Sub
Private Sub Command3_Click()
If Combo2.ListIndex > -1 Then
Call stat2(Combo2.Text)
End If
End Sub
Private Sub Command4_Click()
If Combo3.ListIndex > -1 Then
Call stat3(Combo3.Text)
End If
End Sub
'Private Sub Command5_Click()
' If List1.ListIndex > -1 Then
' DlgPass.addnewstate = False
' DlgPass.Label1.Caption = "旧密码:"
' Text1.PasswordChar = "*"
' DlgPass.Label2.Caption = "新密码:"
' DlgPass.Label3.Caption = "验证:"
' DlgPass.Show 1
'End If
'End Sub
'Private Sub Command6_Click()
' DlgPass.addnewstate = True
'DlgPass.Label1.Caption = "用户名:"
' Text1.PasswordChar = ""
' DlgPass.Label2.Caption = "密码:"
' DlgPass.Label3.Caption = "验证:"
'DlgPass.Show 1
'If DlgPass.upok = True Then
' Freshlist
' End If
'nd Sub
'Private Sub Command7_Click()
'On Error GoTo errh:
'If List1.ListIndex > -1 Then
'If MsgBox("", vbOKCancel, "警告") = vbOK Then
'Dim rs As New ADODB.Recordset
' Set rs = cn.Execute("SELECT * FROM 超级用户 WHERE UserName=" & "'" & List1.List(List1.ListIndex) & "'")
'If rs.EOF Then
' rs.Close
' Exit Sub
' End If
' rs.Delete
' rs.UpdateBatch
' rs.Close
'End If
'End If
'Exit Sub
' MsgBox Err.Description
' Sub
'Private Sub Form_Load()
' MakeCenter Me
' If IsAdmin = True Then
' Command7.Enabled = True
' Else
' Command7.Enabled = False
' End If
'SSTab1.Tab = 0
'GetClass True, Combo1
'End Sub
Private Sub Freshlist()
On Error GoTo errh:
List1.Clear
Dim rs As New ADODB.Recordset
Set rs = cn.Execute("SELECT UserName FROM 用户表")
If rs.EOF Then
rs.Close
Set rs = Nothing
Exit Sub
End If
rs.MoveFirst
Do
List1.AddItem rs.Fields("UserName").Value
rs.MoveNext
Loop Until rs.EOF
rs.Close
Exit Sub
errh:
rs.Close
MsgBox Err.Description
End Sub
Private Sub SSTab1_Click(PreviousTab As Integer)
On Error GoTo errh:
Select Case SSTab1.Tab
Case 0
If Combo1.ListCount < 1 Then
GetClass True, Combo1
End If
Case 1
If Combo2.ListCount < 1 Then
GetClass False, Combo2
End If
Case 2
If Combo3.ListCount < 1 Then
GetClass True, Combo3
End If
Case 3
If List1.ListCount < 1 Then
Freshlist
End If
End Select
Exit Sub
errh:
MsgBox Err.Description
End Sub
Private Sub GetClass(flag As Boolean, combo As ComboBox)
On Error GoTo errh:
Combo1.Clear
Dim s As String
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Set rs = cn.Execute("SELECT 学号 FROM 学生表 ORDER BY 学号 ASC")
If rs.EOF Then
rs.Close
Set rs = Nothing
Exit Sub
End If
rs.MoveFirst
Dim i As Integer
If flag Then
i = 6
Else
i = 8
End If
combo.AddItem Left$(rs.Fields(0).Value, i)
Do
s = Left$(rs.Fields(0).Value, i)
If s <> combo.List(combo.ListCount - 1) Then
combo.AddItem s
End If
rs.MoveNext
Loop Until rs.EOF
combo.Text = "请选择"
rs.Close
Exit Sub
errh:
rs.Close
MsgBox Err.Description
End Sub
Private Sub Stat1(classID As String) '统计某班级学生的总分和平均分
On Error GoTo errh
Text1.Text = Text1.Text & vbCrLf & "***********************"
Text1.Text = Text1.Text & vbCrLf & Combo1.Text
Dim q As String
q = "SELECT 课程表.课程号, 成绩表.成绩, 课程表.课程名称 From 学生表, 课程表, 成绩表 WHERE 学生表.学号 Like" & "'" & classID & "##'And 学生表.学号=成绩表.学号 And 成绩表.课程号=课程表.课程号 ORDER BY 课程表.课程号"
Dim rs As New ADODB.Recordset
Set rs = cn.Execute(q)
If rs.EOF Then
rs.Close
Set rs = Nothing
Exit Sub
End If
rs.MoveFirst
Dim sum As Variant
Dim stdnum As Integer
Dim cid As Integer
Dim cname As String
sum = 0
classID = -1
Do While Not rs.EOF
If cid <> rs.Fields(0).Value Then
If sum > 0 And stdnum > 0 Then
Text1.Text = Text1.Text & vbCrLf & cname & vbCrLf & " 总分为:" & Str(sum) & vbCrLf & " 平均分为: " & Str(sum / stdnum)
End If
sum = 0
stdnum = 0
cid = rs.Fields(0).Value
End If
sum = sum + rs.Fields(1).Value
stdnum = stdnum + 1
cname = rs.Fields(2)
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
Exit Sub
errh:
MsgBox Err.Description
End Sub
Private Sub stat2(stdID As String) '统计某个学生的平均分和总分
On Error GoTo errh
Text2.Text = Text2.Text & vbCrLf & "***********************" & vbCrLf & "学号:" & Combo2.Text
Text2.Text = Text2.Text & vbCrLf & "课程列表:"
Dim q As String
q = "SELECT 成绩表.课程号,课程表.课程号,课程表.课程名称,成绩表.成绩 FROM 学生表,成绩表,课程表 WHERE 学生表.学号=" & "'" & stdID & "'" & "AND 成绩表.学号=学生表.学号 AND 课程表.课程号=成绩表.课程号"
Dim rs As New ADODB.Recordset
Set rs = cn.Execute(q)
If rs.EOF Then
rs.Close
Set rs = Nothing
Exit Sub
End If
rs.MoveFirst
Dim sum As Variant
Dim sn As Integer
sum = 0
sn = 0
Do While Not rs.EOF
sum = sum + rs.Fields(3).Value
sn = sn + 1
Text2.Text = Text2.Text & vbCrLf & rs.Fields(2)
rs.MoveNext
Loop
rs.Close
If sn > 0 Then
Text2.Text = Text2.Text & vbCrLf & "该生总分为:" & Str(sum) & vbCrLf & "平均分为: " & Str(sum / sn)
Else
Text2.Text = Text2.Text & vbCrLf & "没有成绩"
End If
Set rs = Nothing
Exit Sub
errh:
MsgBox Err.Description
End Sub
Private Sub stat3(classID As String) '统计某班不及格的学生
On Error GoTo errh
On Error GoTo errh
Text3.Text = Text3.Text & vbCrLf & "***********************"
Text3.Text = Text3.Text & vbCrLf & Combo3.Text
Dim q As String
q = "SELECT 课程表.课程号, 成绩表.成绩, 课程表.课程名称,学生表.姓名 From 学生表, 课程表, 成绩表 WHERE 学生表.学号 Like" & "'" & classID & "##' And 学生表.学号=成绩表.学号 And 成绩表.课程号=课程表.课程号 ORDER BY 课程表.课程号"
Dim rs As New ADODB.Recordset
Set rs = cn.Execute(q)
If rs.EOF Then
rs.Close
Set rs = Nothing
Exit Sub
End If
rs.MoveFirst
Do While Not rs.EOF
If rs.Fields(1).Value < 60 Then
Text3.Text = Text3.Text & vbCrLf & rs.Fields(3).Value & Space(5) & rs.Fields(2) & Space(5) & rs.Fields(1)
End If
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
Exit Sub
errh:
MsgBox Err.Description
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -