?? form5.frm
字號:
VERSION 5.00
Object = "{DAAC6951-59A4-4C08-9D6E-FE3919B64861}#1.0#0"; "FlexCell.ocx"
Begin VB.Form Form5
Caption = "成績統計圖表"
ClientHeight = 5340
ClientLeft = 60
ClientTop = 345
ClientWidth = 7815
Icon = "Form5.frx":0000
LinkTopic = "Form5"
ScaleHeight = 5340
ScaleWidth = 7815
StartUpPosition = 1 '所有者中心
Begin FlexCell.Grid Grid1
Height = 4815
Left = 240
TabIndex = 0
Top = 240
Width = 7335
_ExtentX = 12938
_ExtentY = 8493
Appearance = 0
Cols = 5
Rows = 30
End
End
Attribute VB_Name = "Form5"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private mblnChanged As Boolean
Private Sub Form_Load()
On Error GoTo finish
Grid1.SetRegisterInformation "CNwinndy", "W]vyY-nonvk-u\nty-Zbl_e-`hms^" '進行注冊
Dim i As Long
Dim ac1, ac2, ac3, ac4, ac5 As Integer
Grid1.AutoRedraw = False
Grid1.CellBorderColorFixed = vbButtonShadow
Grid1.FixedRowColStyle = Flat
Grid1.Rows = 40
Grid1.Cols = 5
Grid1.RowHeight(1) = 30
For i = 1 To 1
Grid1.Column(i).Width = 70
Next
'設置單元格文字
Grid1.Cell(1, 1).Text = tbbm1 '圖表的表名稱
Grid1.Cell(2, 1).Text = "姓 名"
Grid1.Cell(3, 1).Text = "平均分"
Grid1.Cell(4, 1).Text = "最高分"
Grid1.Cell(5, 1).Text = "最低分"
Set qy1 = cnn.Execute(tbsql1)
If qy1.EOF = True Then
MsgBox "無任何對應數據!"
Exit Sub
End If
Do While Not qy1.EOF
Grid1.Cols = Grid1.Cols + 1
Grid1.Cell(2, Grid1.Cols - 1).Text = Mid(qy1.Fields(0), 1, 4) '取值只取四位數,即小數點后一位
Grid1.Cell(3, Grid1.Cols - 1).Text = Mid(qy1.Fields(1), 1, 4)
Grid1.Cell(4, Grid1.Cols - 1).Text = Mid(qy1.Fields(2), 1, 4)
Grid1.Cell(5, Grid1.Cols - 1).Text = Mid(qy1.Fields(3), 1, 4)
qy1.MoveNext
Loop
For i = 1 To Grid1.Cols - 1
Grid1.Column(i).Width = 70
Next
'設置單元格格式
Grid1.Cell(1, 1).Font.SIZE = 10
Grid1.Range(1, 1, 1, Grid1.Cols - 1).Merge
Grid1.Range(1, 1, 5, 1).Alignment = cellCenterCenter
Grid1.Range(2, 1, 2, Grid1.Cols - 1).Alignment = cellCenterCenter
Grid1.Range(3, 2, 5, Grid1.Cols - 1).Alignment = cellRightCenter
Grid1.Range(2, 1, 2, Grid1.Cols - 1).BackColor = RGB(90, 158, 214)
Grid1.Range(2, 1, 5, 1).BackColor = vbYellow
With Grid1.Range(1, 1, 5, Grid1.Cols - 1)
.Borders(cellEdgeLeft) = cellThin
.Borders(cellEdgeRight) = cellThin
.Borders(cellEdgeTop) = cellThin
.Borders(cellEdgeBottom) = cellThin
.Borders(cellInsideHorizontal) = cellThin
.Borders(cellInsideVertical) = cellThin
End With
'添加一個3D柱形圖表,并設置細邊框
With Grid1.Range(7, 1, 15, Grid1.Cols - 1)
.Merge
.Borders(cellEdgeLeft) = cellThin
.Borders(cellEdgeRight) = cellThin
.Borders(cellEdgeTop) = cellThin
.Borders(cellEdgeBottom) = cellThin
End With
Grid1.AddChart 7, 1
With Grid1.Chart(7, 1)
.PlotBy = cellRows
.SetDataSource 2, 1, 5, Grid1.Cols - 1
.ChartType = cell3DColumnClustered
.ScaleFont = False
End With
Set qy2 = cnn.Execute(tbsql2)
Dim cg As Double
'對成績進行圖表顯示
Do While Not qy2.EOF
cg = qy2.Fields(0)
Select Case cg
Case 90 To 150
ac1 = ac1 + 1
Case 80 To 89
ac2 = ac2 + 1
Case 70 To 79
ac3 = ac3 + 1
Case 60 To 69
ac4 = ac4 + 1
Case 0 To 59
ac5 = ac5 + 1
End Select
qy2.MoveNext
Loop
Grid1.Cols = Grid1.Cols + 5
Grid1.Cell(17, 1).Text = "比例統計"
Grid1.Cell(18, 1).Text = "優"
Grid1.Cell(18, 2).Text = "良"
Grid1.Cell(18, 3).Text = "中"
Grid1.Cell(18, 4).Text = "及格"
Grid1.Cell(18, 5).Text = "不及格"
Grid1.Cell(19, 1).Text = ac1
Grid1.Cell(19, 2).Text = ac2
Grid1.Cell(19, 3).Text = ac3
Grid1.Cell(19, 4).Text = ac4
Grid1.Cell(19, 5).Text = ac5
'設置單元格格式
Grid1.Cell(17, 1).Font.SIZE = 11
Grid1.Range(17, 1, 17, 5).Merge
Grid1.Range(17, 1, 17, 5).Alignment = cellCenterCenter
Grid1.Range(18, 1, 19, 5).Alignment = cellCenterCenter
Grid1.Range(18, 1, 18, 5).BackColor = vbYellow
With Grid1.Range(18, 1, 18, 5)
.Borders(cellEdgeLeft) = cellThin
.Borders(cellEdgeRight) = cellThin
.Borders(cellEdgeTop) = cellThin
.Borders(cellEdgeBottom) = cellThin
.Borders(cellInsideHorizontal) = cellThin
.Borders(cellInsideVertical) = cellThin
End With
'添加一個餅圖
With Grid1.Range(22, 1, 32, 5)
.Merge
.Borders(cellEdgeLeft) = cellThin
.Borders(cellEdgeRight) = cellThin
.Borders(cellEdgeTop) = cellThin
.Borders(cellEdgeBottom) = cellThin
End With
Grid1.AddChart 22, 1
With Grid1.Chart(22, 1)
.SetDataSource 18, 1, 19, 5
.ChartType = cell3DPie
.DisplayDataLabels = True
.ScaleFont = False
End With
Grid1.PageSetup.CenterHorizontally = True
'設置打印區域
Grid1.PageSetup.PrintRows = 37
Grid1.PageSetup.PrintColumns = 4
Grid1.AutoRedraw = True
Grid1.Refresh
Exit Sub
finish:
MsgBox Err.Description
'MsgBox "無此對象或其它參數錯誤!"
End Sub
Private Sub Form_Resize()
If Me.WindowState <> 1 Then
Grid1.Left = 240
Grid1.Width = Me.Width - 480
Grid1.Top = 240
Grid1.Height = Me.Height - 960
End If
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -