更新后
我改变了密码就像。
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 ()时,如下所示。它起作用了。
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我在这代码里做错什么了吗?
发布于 2017-04-09 13:47:57
稍微清理一下:
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 / (1 + d))
End Function
Sub MAIN()
MsgBox Isokinectic(0.1, 0.2, 0.3, 0.4, 0.5, 0.6)
End Sub

发布于 2017-04-09 15:48:28
在您最初的文章中,您已经计算了s,d,stk,但是在后面的阶段中,您没有得到值的值&其他,是值错误的原因。由于您在公式中使用了一个子程序,所以请将函数中的命令行写入函数中,不要忘记从单元格中传递值。
https://stackoverflow.com/questions/43306981
复制相似问题