一个利用ACCESS数据库进行统计
源代码在线查看: 描述统计f2.frm
VERSION 5.00
Begin VB.Form frmCalculate
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "描述统计数"
ClientHeight = 4890
ClientLeft = 165
ClientTop = 555
ClientWidth = 4890
LinkTopic = "Form1"
ScaleHeight = 8.625
ScaleMode = 7 'Centimeter
ScaleWidth = 8.625
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton cmdExit
Caption = "退 出"
Height = 375
Left = 3360
TabIndex = 3
Top = 1560
Width = 1095
End
Begin VB.CommandButton cmdSave
Caption = "保 存"
Height = 375
Left = 3360
TabIndex = 2
Top = 1080
Width = 1095
End
Begin VB.CommandButton cmdPrint
Caption = "打 印"
Height = 375
Left = 3360
TabIndex = 1
Top = 600
Width = 1095
End
Begin VB.CommandButton cmdCalculate
Caption = "计 算"
Height = 375
Left = 3360
TabIndex = 0
Top = 120
Width = 1095
End
Begin VB.Label lblValue
Appearance = 0 'Flat
BackColor = &H80000005&
ForeColor = &H80000008&
Height = 375
Index = 9
Left = 1560
TabIndex = 23
Top = 4440
Width = 1575
End
Begin VB.Label lblValue
Appearance = 0 'Flat
BackColor = &H80000005&
ForeColor = &H80000008&
Height = 375
Index = 8
Left = 1560
TabIndex = 22
Top = 3960
Width = 1575
End
Begin VB.Label lblValue
Appearance = 0 'Flat
BackColor = &H80000005&
ForeColor = &H80000008&
Height = 375
Index = 7
Left = 1560
TabIndex = 21
Top = 3480
Width = 1575
End
Begin VB.Label lblValue
Appearance = 0 'Flat
BackColor = &H80000005&
ForeColor = &H80000008&
Height = 375
Index = 6
Left = 1560
TabIndex = 20
Top = 3000
Width = 1575
End
Begin VB.Label lblValue
Appearance = 0 'Flat
BackColor = &H80000005&
ForeColor = &H80000008&
Height = 375
Index = 5
Left = 1560
TabIndex = 19
Top = 2520
Width = 1575
End
Begin VB.Label lblValue
Appearance = 0 'Flat
BackColor = &H80000005&
ForeColor = &H80000008&
Height = 375
Index = 4
Left = 1560
TabIndex = 18
Top = 2040
Width = 1575
End
Begin VB.Label lblValue
Appearance = 0 'Flat
BackColor = &H80000005&
ForeColor = &H80000008&
Height = 375
Index = 3
Left = 1560
TabIndex = 17
Top = 1560
Width = 1575
End
Begin VB.Label lblValue
Appearance = 0 'Flat
BackColor = &H80000005&
ForeColor = &H80000008&
Height = 375
Index = 2
Left = 1560
TabIndex = 16
Top = 1080
Width = 1575
End
Begin VB.Label lblValue
Appearance = 0 'Flat
BackColor = &H80000005&
ForeColor = &H80000008&
Height = 375
Index = 1
Left = 1560
TabIndex = 15
Top = 600
Width = 1575
End
Begin VB.Label lblValue
Appearance = 0 'Flat
BackColor = &H80000005&
ForeColor = &H80000008&
Height = 375
Index = 0
Left = 1560
TabIndex = 14
Top = 120
Width = 1575
End
Begin VB.Label lblTitle
Alignment = 1 'Right Justify
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "峰度系数:"
ForeColor = &H80000008&
Height = 375
Index = 9
Left = 120
TabIndex = 13
Top = 4440
Width = 1335
End
Begin VB.Label lblTitle
Alignment = 1 'Right Justify
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "偏度系数:"
ForeColor = &H80000008&
Height = 375
Index = 8
Left = 120
TabIndex = 12
Top = 3960
Width = 1335
End
Begin VB.Label lblTitle
Alignment = 1 'Right Justify
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "标准差:"
ForeColor = &H80000008&
Height = 375
Index = 7
Left = 120
TabIndex = 11
Top = 3480
Width = 1335
End
Begin VB.Label lblTitle
Alignment = 1 'Right Justify
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "方差:"
ForeColor = &H80000008&
Height = 375
Index = 6
Left = 120
TabIndex = 10
Top = 3000
Width = 1335
End
Begin VB.Label lblTitle
Alignment = 1 'Right Justify
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "平均差:"
ForeColor = &H80000008&
Height = 375
Index = 5
Left = 120
TabIndex = 9
Top = 2520
Width = 1335
End
Begin VB.Label lblTitle
Alignment = 1 'Right Justify
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "范围:"
ForeColor = &H80000008&
Height = 375
Index = 4
Left = 120
TabIndex = 8
Top = 2040
Width = 1335
End
Begin VB.Label lblTitle
Alignment = 1 'Right Justify
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "几何平均数:"
ForeColor = &H80000008&
Height = 375
Index = 3
Left = 120
TabIndex = 7
Top = 1560
Width = 1335
End
Begin VB.Label lblTitle
Alignment = 1 'Right Justify
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "众数:"
ForeColor = &H80000008&
Height = 375
Index = 2
Left = 120
TabIndex = 6
Top = 1080
Width = 1335
End
Begin VB.Label lblTitle
Alignment = 1 'Right Justify
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "中位数:"
ForeColor = &H80000008&
Height = 375
Index = 1
Left = 120
TabIndex = 5
Top = 600
Width = 1335
End
Begin VB.Label lblTitle
Alignment = 1 'Right Justify
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "算术平均数:"
ForeColor = &H80000008&
Height = 375
Index = 0
Left = 120
TabIndex = 4
Top = 120
Width = 1335
End
End
Attribute VB_Name = "frmCalculate"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'计算窗体
Dim R(1 To 10) As Double, S(1 To 10) As Single, I As Integer
Dim strFileOut As String, intFileOut As Integer
Private Sub Form_Load()
cmdPrint.Visible = False '“打印”命令按钮不可视
cmdSave.Visible = False '“保存”命令按钮不可视
End Sub
'计算
Private Sub cmdCalculate_Click()
Character V, R '调用标准模块中计算描述统计数的过程
'将计算结果放入标签显示
For I = 1 To 10
If R(I) < 90000000 Then
S(I) = R(I)
lblValue(I - 1).Caption = S(I)
Else
lblValue(I - 1).Caption = "无效"
End If
Next I
cmdPrint.Visible = True '“打印”命令按钮可视
cmdSave.Visible = True '“保存”命令按钮可视
End Sub
'打印
Private Sub cmdPrint_Click()
MsgBox "现在开始打印,请稍侯"
Printer.Print
With Printer
.FontName = "隶书"
.FontSize = 20
End With
Printer.Print Spc(8); "描述统计数"
With Printer
.FontName = "宋体"
.FontSize = 14
End With
For I = 1 To 10
Printer.Print Spc(8); lblTitle(I - 1).Caption, lblValue(I - 1).Caption
Next I
Printer.EndDoc
MsgBox "打印文档已交付打印设备,请继续其他工作"
End Sub
'保存
Private Sub cmdSave_Click()
strFileOut = frmFile.txtResult.Text '文件名
intFileOut = FreeFile '取得空闲的文件号码
Open strFileOut For Output As intFileOut
Print #intFileOut, "描述统计数"
'将计算结果写入文件
For I = 1 To 10
Print #intFileOut, lblTitle(I - 1).Caption; lblValue(I - 1).Caption
Next I
Close #intFileOut '关闭文件
End Sub
'退出
Private Sub cmdExit_Click()
Unload Me
End
End Sub