数理统计程序集
源代码在线查看: 正态分布图f.frm
VERSION 5.00
Begin VB.Form frmNorm
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "正态分布"
ClientHeight = 2250
ClientLeft = 60
ClientTop = 450
ClientWidth = 4980
LinkTopic = "Form1"
ScaleHeight = 2250
ScaleWidth = 4980
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton cmdNew
Caption = "重 作"
Height = 375
Left = 3960
TabIndex = 14
Top = 1680
Width = 735
End
Begin VB.CommandButton cmdExit
Caption = "退 出"
Height = 375
Left = 3120
TabIndex = 13
Top = 1680
Width = 735
End
Begin VB.CommandButton cmdCalculate
Caption = "计 算"
Height = 375
Left = 2280
TabIndex = 12
Top = 1680
Width = 735
End
Begin VB.TextBox Text5
Alignment = 2 'Center
Appearance = 0 'Flat
Height = 270
Left = 3120
TabIndex = 11
Top = 960
Width = 1215
End
Begin VB.TextBox Text4
Alignment = 2 'Center
Appearance = 0 'Flat
Height = 270
Left = 1560
TabIndex = 8
Top = 1680
Width = 615
End
Begin VB.TextBox Text3
Alignment = 2 'Center
Appearance = 0 'Flat
Height = 270
Left = 1560
TabIndex = 7
Top = 1320
Width = 615
End
Begin VB.TextBox Text2
Alignment = 2 'Center
Appearance = 0 'Flat
Height = 270
Left = 1560
TabIndex = 6
Top = 960
Width = 615
End
Begin VB.TextBox Text1
Alignment = 2 'Center
Appearance = 0 'Flat
Height = 270
Left = 1560
TabIndex = 5
Top = 600
Width = 615
End
Begin VB.Label Label7
Alignment = 1 'Right Justify
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "偏离点之间的概率"
ForeColor = &H80000008&
Height = 255
Left = 2520
TabIndex = 10
Top = 600
Width = 1935
End
Begin VB.Label Label6
Alignment = 2 'Center
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "计算结果"
ForeColor = &H80000008&
Height = 255
Left = 3000
TabIndex = 9
Top = 240
Width = 1455
End
Begin VB.Label Label5
Alignment = 1 'Right Justify
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "偏离点2:"
ForeColor = &H80000008&
Height = 255
Left = 240
TabIndex = 4
Top = 1680
Width = 1215
End
Begin VB.Label Label4
Alignment = 1 'Right Justify
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "偏离点1:"
ForeColor = &H80000008&
Height = 255
Left = 240
TabIndex = 3
Top = 1320
Width = 1215
End
Begin VB.Label Label3
Alignment = 1 'Right Justify
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "标准差:"
ForeColor = &H80000008&
Height = 255
Left = 240
TabIndex = 2
Top = 960
Width = 1215
End
Begin VB.Label Label2
Alignment = 1 'Right Justify
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "平均值:"
ForeColor = &H80000008&
Height = 255
Left = 240
TabIndex = 1
Top = 600
Width = 1215
End
Begin VB.Label Label1
Alignment = 2 'Center
Appearance = 0 'Flat
BackColor = &H80000005&
Caption = "输入数据"
ForeColor = &H80000008&
Height = 255
Left = 360
TabIndex = 0
Top = 240
Width = 1815
End
End
Attribute VB_Name = "frmNorm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'计算
Private Sub cmdCalculate_Click()
Dim A As Double, B As Double
Dim C As Double, D As Double
Dim X1 As Double, X2 As Double
Dim p1 As Double, p2 As Double
A = Val(Text1.Text): B = Val(Text2.Text)
C = Val(Text3.Text): D = Val(Text4.Text)
X1 = (C - A) / B: X2 = (D - A) / B '标准化
Norm X1, p1 '求下侧概率
Norm X2, p2 '求下侧概率
'计算结果取小数点后两位,第3位小数4舍5入
Text5.Text = Str((Int(Abs(p1 - p2) * 10000 + 0.5)) / 100) & "%"
End Sub
'退出
Private Sub cmdExit_Click()
Unload Me
End
End Sub
'重作
'清除文本框
Private Sub cmdNew_Click()
Dim ctlT As Control
On Error Resume Next
For Each ctlT In Controls
ctlT.Text = ""
Next
End Sub