VBA---通過Z值算PPM
以下VBA宏放在Excel, word中都可以運行,各一個參數Z值就可以算出對應的PPM
Private Function SToPPM(Z As Double) As Double
Dim GPI As Double
Dim DX As Double
Dim temp As Double
Dim Count As Long
Dim Y1 As Double, Y2 As Double
DX = 0.01
GPI = 1 / Sqr(2 3.1415926) 1000000
Y2 = GPI Exp(-0.5 Z* Z)
Count = 0
SToPPM = 0
Do While Y2 > 0.00001
Y1 = Y2
Count = Count + 1
If Z> 0 Then
Y2 = GPI Exp(-0.5 (Z+ DX Count) (Z+ DX * Count))
Else
Y2 = GPI Exp(-0.5 (Z- DX Count) (Z- DX * Count))
End If
SToPPM = SToPPM + ((Y1 + Y2) * DX) / 2
Loop
SToPPM = SToPPM
End Function
Private Function SToPPM(Z As Double) As Double
Dim GPI As Double
Dim DX As Double
Dim temp As Double
Dim Count As Long
Dim Y1 As Double, Y2 As Double
DX = 0.01
GPI = 1 / Sqr(2 3.1415926) 1000000
Y2 = GPI Exp(-0.5 Z* Z)
Count = 0
SToPPM = 0
Do While Y2 > 0.00001
Y1 = Y2
Count = Count + 1
If Z> 0 Then
Y2 = GPI Exp(-0.5 (Z+ DX Count) (Z+ DX * Count))
Else
Y2 = GPI Exp(-0.5 (Z- DX Count) (Z- DX * Count))
End If
SToPPM = SToPPM + ((Y1 + Y2) * DX) / 2
Loop
SToPPM = SToPPM
End Function
没有找到相关结果
已邀请:
6 个回复
clarkbao (威望:0) - 品質工程師
赞同来自:
清空所有代码,再把上面的代码复制进去就可以了