更新後的帖子如何在Excel函數中聲明變量?
我改變了代碼。
Option Explicit
Public Function Isokinectic(streamVelocity As Double, sampleVelocity As Double, probeDiameter As Double, density As Double, particleDiameter As Double, viscosity As Double)
Dim s As Double
Dim stk_coefficent As Double
Dim stk As Double
Dim d As Double
s = ((0.16 * 10^-4)/particleDiameter) + 1
stk_coefficent = (1/(18 * viscosity)) * density * particleDiameter * particleDiameter * s
stk = (streamVelocity/probeDiameter) * stk_coefficent
d = 1 + (2 + 0.62 * (sampleVelocity/streamVelocity)) * stk
Isokinectic = 1 + ((streamVelocity/sampleVelocity) - 1) * (1 - 1/(d))
End Function
但它不起作用。但是,添加sub MAIN()時,就像這樣。有用。
Option Explicit
Function Isokinectic(streamVelocity As Double, sampleVelocity As Double, probeDiameter As Double, density As Double, particleDiameter As Double, viscosity As Double)
Dim s As Double
Dim stk_coefficent As Double
Dim stk As Double
Dim d As Double
s = ((0.16 * 10^-4)/particleDiameter) + 1
stk_coefficent = (1/(18 * viscosity)) * density * particleDiameter * particleDiameter * s
stk = (streamVelocity/probeDiameter) * stk_coefficent
d = 1 + (2 + 0.62 * (sampleVelocity/streamVelocity)) * stk
Isokinectic = 1 + ((streamVelocity/sampleVelocity) - 1) * (1 - 1/(d))
End Function
Sub MAIN()
MsgBox Isokinectic(0.1, 0.2, 0.3, 0.4, 0.5, 0.6)
End Sub
原貼:
我試圖代碼Excel函數方程。但我得到了#值
Function Isokinectic(streamVelocity As Double, sampleVelocity As Double, probeDiameter As Double, density As Double, particleDiamter As Double, visocity As Double)
Dim s As Double
Dim stk_coefficent As Double
Dim stk As Double
Dim d As Double
s = (0.16 * 10^ - 4/particleDiameter) + 1
stk_coefficent = (1/(18 * viscosity)) * density * particleDiamter * particleDiameter * s
stk = (streamVelocity/probeDiameter) * stk_coefficent
d = 1 + (2 + 0.62 * (sampleVelocity/streamVelocity)) * stk
Isokinectic = 1 + ((streamVelocity/sampleVelocity) - 1) * (1 - 1/(1 + d))
End Function
任何我在這段代碼中做錯了嗎?
它對我來說運行良好。你怎麼打電話?> –
插入功能。然後輸入變量。 – JOHN
錯字標題*** particleDiamter ***不是*** particleDiameter ***可能還有其他問題 –