📄 frmstatistic.frm
字号:
VERSION 5.00
Begin VB.Form frmStatistic
BorderStyle = 1 'Fixed Single
Caption = "统计数据"
ClientHeight = 3120
ClientLeft = 45
ClientTop = 435
ClientWidth = 6765
Icon = "frmStatistic.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3120
ScaleWidth = 6765
StartUpPosition = 1 '所有者中心
Begin VB.Frame fraStatistic
Caption = "数据"
Height = 2775
Left = 2400
TabIndex = 2
Top = 240
Width = 4335
Begin VB.Label lblStd
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Height = 255
Left = 1200
TabIndex = 14
Top = 2760
Width = 2775
End
Begin VB.Label lblTotal
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Height = 255
Left = 1200
TabIndex = 13
Top = 2280
Width = 2775
End
Begin VB.Label lblMean
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Height = 255
Left = 1200
TabIndex = 12
Top = 1800
Width = 2775
End
Begin VB.Label lblMin
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Height = 255
Left = 1200
TabIndex = 11
Top = 1320
Width = 2775
End
Begin VB.Label lblMax
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Height = 255
Left = 1200
TabIndex = 10
Top = 840
Width = 2775
End
Begin VB.Label lblNumber
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Height = 255
Left = 1200
TabIndex = 9
Top = 360
Width = 2775
End
Begin VB.Line Line6
X1 = 960
X2 = 960
Y1 = 240
Y2 = 2640
End
Begin VB.Label Label7
BackStyle = 0 'Transparent
Caption = "标准差:"
Height = 255
Left = 240
TabIndex = 8
Top = 2880
Width = 735
End
Begin VB.Label Label6
BackStyle = 0 'Transparent
Caption = "总数量:"
Height = 255
Left = 240
TabIndex = 7
Top = 2280
Width = 735
End
Begin VB.Label Label5
BackStyle = 0 'Transparent
Caption = "纪录数:"
Height = 255
Left = 240
TabIndex = 6
Top = 360
Width = 735
End
Begin VB.Label Label4
BackStyle = 0 'Transparent
Caption = "平均值:"
Height = 255
Left = 240
TabIndex = 5
Top = 1800
Width = 735
End
Begin VB.Label Label3
BackStyle = 0 'Transparent
Caption = "最小值:"
Height = 255
Left = 240
TabIndex = 4
Top = 1320
Width = 855
End
Begin VB.Label Label2
BackStyle = 0 'Transparent
Caption = "最大值:"
Height = 255
Left = 240
TabIndex = 3
Top = 840
Width = 735
End
Begin VB.Line Line5
X1 = 120
X2 = 4200
Y1 = 2640
Y2 = 2640
End
Begin VB.Line Line4
X1 = 120
X2 = 4200
Y1 = 2160
Y2 = 2160
End
Begin VB.Line Line3
X1 = 120
X2 = 4200
Y1 = 1680
Y2 = 1680
End
Begin VB.Line Line2
X1 = 120
X2 = 4200
Y1 = 1200
Y2 = 1200
End
Begin VB.Line Line1
X1 = 120
X2 = 4200
Y1 = 720
Y2 = 720
End
Begin VB.Shape Shape1
BackStyle = 1 'Opaque
Height = 2415
Left = 120
Top = 240
Width = 4095
End
End
Begin VB.ListBox lstField
Height = 2580
Left = 120
TabIndex = 1
Top = 360
Width = 2175
End
Begin VB.Label Label1
Caption = "清选择需要查询的字段"
Height = 255
Left = 120
TabIndex = 0
Top = 120
Width = 2055
End
End
Attribute VB_Name = "frmStatistic"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'------------------------------------------------------------------
'2002-11-11,根据frmtracksearch修改统计数据计算方法
'2002-10-16,窗口建立,用来显示某字段的统计数据
'------------------------------------------------------------------
Private Sub RefreshStatistic(strField As String)
'统计某字段的数据
Dim lMax As Long
Dim lMin As Long
Dim lSum As Long
Dim lpRecord As Long
Dim lValue As Long
With frmTrackSearch.lstInfo
If .ListItems.Count > 0 Then
lMax = Val(.ListItems(1).ListSubItems(strField).text)
lMin = lMax
For lpRecord = 1 To frmTrackSearch.lstInfo.ListItems.Count
lValue = Val(.ListItems(lpRecord).ListSubItems( _
strField).text)
If lMax < lValue Then
lMax = lValue
End If
If lMin > lValue Then
lMin = lValue
End If
lSum = lSum + lValue
DoEvents
Next lpRecord
End If
End With
'显示统计数据
lblNumber.Caption = CStr(frmTrackSearch.lstInfo.ListItems.Count)
lblMax.Caption = CStr(lMax)
lblMin.Caption = CStr(lMin)
lblMean.Caption = frmMain.Get2Decimal(lSum / _
frmTrackSearch.lstInfo.ListItems.Count)
lblTotal.Caption = CStr(lSum)
End Sub
Private Sub RefreshField()
'在列表框中显示所有字段
Dim ListX As ListItem
For Each ListX In frmTrackSearch.lstFieldAttr.ListItems
If Val(ListX.ListSubItems("Type").text) = 3 Or Val(ListX.ListSubItems("Type").text) = 5 Then
lstField.AddItem ListX.Key
End If
Next
End Sub
Private Sub Form_Load()
'显示所有字段
Call RefreshField
End Sub
Private Sub lstField_Click()
'列表框单击事件
If lstField.ListIndex >= 0 Then
'统计当前字段的数据
Call RefreshStatistic(lstField.List(lstField.ListIndex))
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -