📄 frma.frm
字号:
Attribute VB_Name = "FRMA"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim db As Database
Dim rs As Recordset
Dim STR As String
Dim 总人数 As Long
Dim 总人数A As String
Dim s As String
Dim nmc As String
Dim intRecCount As Long
Dim intCounter As Long
Dim XSA As String
Dim 班数 As String
Dim qqq As Long
Dim ii As Long
Private Sub Combo1_Click()
On Error Resume Next
s = "select 学号,姓名,性别,班级,分数 from NHB nhb where 班级= " & Combo1 & " ORDER BY " & "" & Combo3.Text & " desc"
cmbSource
For III = 1 To VF.Rows - 1
VF.TextMatrix(III, 0) = III
Next
For qqq = 0 To VF.Cols - 1
VF.ColAlignment(qqq) = flexAlignCenterCenter
' VSFlexGrid1.CellAlignment = flexAlignCenterCenter
Next qqq
End Sub
Private Sub Combo2_Click()
On Error Resume Next
vp.Columns = Combo2.Text
cmbSource
End Sub
Private Sub Combo3_Click()
On Error Resume Next
s = "select 学号,姓名,性别,班级,分数 from NHB nhb where 班级= " & Combo1 & " ORDER BY " & "" & Combo3.Text & " desc"
cmbSource
For III = 1 To VF.Rows - 1
VF.TextMatrix(III, 0) = III
Next
For qqq = 0 To VF.Cols - 1
VF.ColAlignment(qqq) = flexAlignCenterCenter
' VSFlexGrid1.CellAlignment = flexAlignCenterCenter
Next qqq
End Sub
Private Sub Command3_Click()
End Sub
Private Sub Form_Load()
On Error Resume Next
'对打印的显示百分值进行初始化
cmbPercent.ListIndex = 0
cmbZoomMode.ListIndex = 3
Combo3.ListIndex = 3
Combo2.ListIndex = 1
With vp
.PaperSize = pprA4
.Orientation = orLandscape
.HdrColor = vbRed
End With
Set db = OpenDatabase(MAIN.Cmd1.FileName)
Set rs = db.OpenRecordset("SELECT * FROM NAME")
nmc = rs![Name]
db.Close
Skin1.ApplySkin Me.hwnd
' If MAIN.CMD1.FileName = "" Then MsgBox "请指定一个数据后,才能进行分析处理。", 32, "无法操作": Exit Sub
Dim a
班数 = InputBox("请输入总班级数:(只能输入数字)", "班级自动分配")
If 班数 = "" Then
Exit Sub
Else
Set db = OpenDatabase(MAIN.Cmd1.FileName)
Set rs = db.OpenRecordset("SELECT COUNT(*) AS TOTAL FROM NHB")
总人数 = rs![TOTAL]
If 总人数 / 班数 - CByte(总人数 / 班数) > 0 Then
总人数A = CByte(总人数 / 班数) + 1
Else
总人数A = CByte(总人数 / 班数)
End If
Dim AW As Long
For AW = 1 To 班数
Combo1.AddItem AW
Next
Combo1.ListIndex = 0
WATING.Show
DoEvents
WATING.Label1.Visible = False
WATING.Label2.Visible = True
WATING.PB.Visible = True
WATING.Label2.Caption = "载入智能引擎"
WATING.PB.Max = 班数
WATING.PB1.Max = 总人数
WATING.PB.Value = 0
WATING.PB1.Value = 0
DoEvents
DoEvents
' Me.Caption = 总人数A
DoEvents
Data1.DatabaseName = MAIN.Cmd1.FileName
Data1.RecordSource = "select ID,分数,班级 from NHB ORDER BY 分数 desc"
Data1.Refresh
Dim III As Long
For III = 1 To VF.Rows - 1
VF.TextMatrix(III, 0) = III
VF.TextMatrix(III, 1) = III
VF.TextMatrix(III, 3) = 1
Next
DoEvents
Dim QQ As Long
For QQ = 2 To 班数
Data1.DatabaseName = MAIN.Cmd1.FileName
Data1.RecordSource = "select ID,分数,班级 from NHB where ID>" & 总人数A & " ORDER BY 分数 desc"
Data1.Refresh
DoEvents
Dim IIIAA As Long
For IIIAA = 1 To VF.Rows - 1
VF.TextMatrix(IIIAA, 1) = IIIAA
VF.TextMatrix(IIIAA, 3) = QQ
DoEvents
WATING.Label2.Caption = "正在智能分析 " & QQ & "--" & IIIAA
DoEvents
WATING.PB.Value = 0
DoEvents
WATING.PB.Value = QQ
DoEvents
WATING.PB1.Value = IIIAA
DoEvents
Next
Next QQ
' '
End If
' Me.Caption = "select ID,分数 from NHB where id>" & 总人数A & " ORDER BY 分数 desc"
' DoEvents
DoEvents
WATING.PB.Value = SMA
WATING.Label2.Caption = "分析完毕"
DoEvents
WATING.Label1.Visible = True
WATING.Label2.Visible = False
WATING.PB.Visible = False
Unload WATING
Call Combo1_Click
End Sub
Private Sub Command1_Click()
On Error Resume Next
' Skin1.LoadSkin App.Path & "\SKIN\0.sk"
' Skin1.ApplySkinByName hwnd, "Form"
'' Skin1.ApplySkin Me.hwnd
VF.Visible = False
Toolbar2.Visible = False
vp.Visible = True
Toolbar1.Visible = True
End Sub
Private Sub Command2_Click()
On Error Resume Next
' Skin1.LoadSkin App.Path & "\SKIN\3.sk"
' Skin1.ApplySkinByName hwnd, "Form"
Skin1.ApplySkin Me.hwnd
VF.Visible = True
Toolbar2.Visible = True
vp.Visible = False
Toolbar1.Visible = False
End Sub
Private Sub Command4_Click()
On Error Resume Next
Unload Me
End Sub
Private Sub Form_Resize()
On Error Resume Next
VF.Width = Me.Width - 100
VF.Height = Me.Height - Toolbar1.Height - 780
VF.Top = Toolbar1.Height
VF.Left = 0
vp.Width = Me.Width - 150
vp.Height = Me.Height - Toolbar2.Height - 400
vp.Top = Toolbar2.Height
vp.Left = 0
End Sub
Private Sub Form_Unload(Cancel As Integer)
On Error Resume Next
MAIN.Enabled = True
Unload sca
Dim ws As Workspace
Dim db As Database
Dim rs As Recordset
For Each ws In Workspaces
For Each db In ws.Databases
For Each rs In db.Recordsets
rs.Close
Set rs = Nothing
Next
db.Close
Set db = Nothing
Next
ws.Close
Set ws = Nothing
Next
End Sub
Private Sub Print_Click()
'开始打印
On Error Resume Next
If vp.PageCount > 0 Then vp.PrintDoc
End Sub
Private Sub scrlPage_Change()
'操作 scrlpage 时同时对下面的当前页显示值进行控制
On Error Resume Next
scrlPage.SmallChange = vp.PreviewPages
scrlPage.LargeChange = scrlPage.SmallChange
vp.PreviewPage = scrlPage.Value
Dim lp%
lp = vp.PreviewPage + vp.PreviewPages - 1
If lp > vp.PageCount Then lp = vp.PageCount
If lp < vp.PreviewPage Then lp = vp.PreviewPage
If lp > vp.PreviewPage Then
lblPage = vp.PreviewPage & " - " & lp & " of " & vp.PageCount
Else
lblPage = vp.PreviewPage & " of " & vp.PageCount
End If
'操作 scrlpage 时同时对下面的当前页显示值进行控制
End Sub
Private Sub vp_EndPage()
'得到总页数,并且 scrlpage 自动适应其状态
On Error Resume Next
scrlPage.Max = vp.PageCount
scrlPage.Value = vp.PreviewPage
scrlPage_Change
DoEvents
'得到总页数,并且 scrlpage 自动适应其状态
End Sub
Sub RenderRecordset(vp As VSPrinter, rs As Recordset, ByVal maxh As Double)
On Error Resume Next
Dim arr, i%, j%, wid!
' read recordset into an array
rs.MoveLast
rs.MoveFirst
i = rs.RecordCount
If i = 0 Then Exit Sub
arr = rs.GetRows(i)
' create table header and dummy format
Dim fmt$, hdr$
For i = 0 To rs.Fields.Count - 1
If i > 0 Then hdr = hdr & "|"
fmt = fmt & "|"
hdr = hdr & rs.Fields(i).Name
fmt = fmt & 0
Next
' create table
vp.StartTable
vp.AddTableArray fmt, hdr, arr
' format table
For i = 0 To rs.Fields.Count - 1
' right-align numbers and dates
Select Case rs.Fields(i).Type
Case dbBigInt, dbByte, dbChar, dbCurrency, dbDecimal, dbDouble, dbFloat, dbInteger, dbLong, dbNumeric, dbSingle, dbDate
vp.TableCell(tcColAlign, , i + 1) = taCenterMiddle
End Select
' set column width
If rs.Fields(i).Type = dbMemo Then
vp.TableCell(tcColWidth, , i + 1) = "2.5in"
Else
fmt = ""
For j = 0 To UBound(arr, 2)
If j > 100 Then Exit For
If Len(fmt) < Len(arr(i, j)) Then
fmt = arr(i, j)
End If
Next
If Len(rs.Fields(i).Name) > Len(fmt) Then fmt = rs.Fields(i).Name
' vp.TableCell(tcColWidth, , i + 1) = vp.TextWidth(fmt) * 13
vp.TableCell(tcColWidth, , i + 1) = (vp.PageWidth - vp.MarginLeft - vp.MarginRight) / rs.Fields.Count
End If
Next
' format header row (0)
vp.TableCell(tcFontBold, 0) = True '设置表关字体的粗细
vp.TableCell(tcBackColor, 0) = vbYellow '设置表关字体的颜色
vp.TableCell(tcRowHeight, 0) = vp.TextHeight("Test") * 2.5 '设置表关字体的高度
vp.TableCell(tcAlign, 0) = taCenterMiddle '设置表格头参数,字体居中
'
' make sure it all fits
For i = 1 To vp.TableCell(tcCols)
wid = wid + vp.TableCell(tcColWidth, , i) '设置左右参数
Next
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Dim ii As Long
For ii = 1 To vp.TableCell(tcRows)
vp.TableCell(tcAlign, ii) = taCenterMiddle '设置表格内容居中显示
Next
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
vp.GetMargins
If wid > vp.X2 - vp.X1 Then
wid = (vp.X2 - vp.X1) / wid * 0.95
For i = 1 To vp.TableCell(tcCols)
vp.TableCell(tcColWidth, , i) = wid * vp.TableCell(tcColWidth, , i)
Next
End If
' honor maximum row height
If maxh > 0 Then
For i = 1 To vp.TableCell(tcRows)
If vp.TableCell(tcRowHeight, i) > maxh Then
vp.TableCell(tcRowHeight, i) = maxh
End If
Next
End If
' done with table
vp.EndTable
End Sub
Sub cmbSource()
'打印代码从此处载入
On Error Resume Next
MousePointer = vbHourglass
Dim i%
Data1.RecordSource = s
Data1.Refresh
Dim rs As Recordset
Set rs = Data1.Recordset
With vp
.PenColor = RGB(0, 0, 255)
.StartDoc
nhb = GetProfile(App.Path & "\SET.ini", "学校", "校名")
.Footer = "打印日期:" & Format(Date, "Long Date") & "||注:(此班级共有学生" & VF.Rows - 1 & "人)"
.Header = nhb & vbCrLf & vbCrLf & "|" & nmc & "(" & Combo1.Text & ")班学生名单 (共" & 班数 & "个班级)|当前页 %d"
RenderRecordset vp, rs, 0
.EndDoc
.ScrollIntoView 0, 0
End With
MousePointer = vbDefault
End Sub
Private Sub btnFont_Click()
On Error Resume Next
Me.Enabled = False
'设置字体等项目
With Me.vp
CommonDialog1.Flags = cdlCFBoth + cdlCFEffects
CommonDialog1.FontName = .FontName
CommonDialog1.FontSize = .FontSize
CommonDialog1.FontBold = .FontBold
CommonDialog1.FontItalic = .FontItalic
CommonDialog1.FontUnderline = .FontUnderline
CommonDialog1.FontStrikethru = .FontStrikethru
' CommonDialog1.Color = .PenColor
CommonDialog1.ShowFont
.FontName = CommonDialog1.FontName
.FontSize = CommonDialog1.FontSize
.FontBold = CommonDialog1.FontBold
.FontItalic = CommonDialog1.FontItalic
.FontUnderline = CommonDialog1.FontUnderline
.FontStrikethru = CommonDialog1.FontStrikethru
.PenColor = CommonDialog1.Color
.TextColor = CommonDialog1.Color
End With
DoEvents
cmbSource
Me.Enabled = True
End Sub
Private Sub SETHARD_Click()
On Error Resume Next
Me.Enabled = False
With Me.vp
CommonDialog2.Flags = cdlCFBoth + cdlCFEffects
CommonDialog2.FontName = .HdrFontName
CommonDialog2.FontSize = .HdrFontSize
CommonDialog2.FontBold = .HdrFontBold
CommonDialog2.FontItalic = .HdrFontItalic
CommonDialog2.FontUnderline = .HdrFontUnderline
CommonDialog2.FontStrikethru = .HdrFontStrikethru
CommonDialog2.Color = .HdrColor
CommonDialog2.ShowFont
.HdrFontName = CommonDialog2.FontName
.HdrFontSize = CommonDialog2.FontSize
.HdrFontBold = CommonDialog2.FontBold
.HdrFontItalic = CommonDialog2.FontItalic
.HdrFontUnderline = CommonDialog2.FontUnderline
.HdrFontStrikethru = CommonDialog2.FontStrikethru
.HdrColor = CommonDialog2.Color
End With
DoEvents
cmbSource
Me.Enabled = True
End Sub
Private Sub cmdPageSetup_Click()
'调出页面设置界面
On Error Resume Next
Me.Enabled = False
vp.PrintDialog pdPageSetup
cmbSource
Me.Enabled = True
End Sub
Private Sub cmbPercent_Click()
'进行百分比操作
On Error Resume Next
vp.Zoom = Val(cmbPercent.List(cmbPercent.ListIndex))
End Sub
Private Sub cmbZoomMode_Click()
'当选择了自定义时,则自定义参数生效
On Error Resume Next
If cmbZoomMode.ListIndex = 0 Then
cmbPercent_Click
cmbPercent.Enabled = True
Else
cmbPercent.Enabled = False
vp.ZoomMode = cmbZoomMode.ListIndex
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -