Aktualisierter BeitragWie deklariert man Variablen innerhalb der Excel-Funktion?
Ich habe den Code wie geändert.
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
Aber es funktioniert nicht. Wenn Sie jedoch den Unterbefehl MAIN() hinzufügen, so. Es klappt.
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
Original-Beitrag:
Ich habe versucht, eine Gleichung in Excel-Funktion zu codieren. Aber ich habe #value
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
Alles, was ich in diesem Code falsch gemacht?
Es läuft gut für mich. Wie nennst du es?> –
Funktion einfügen. Dann tippe die Variablen ein. – JOHN
Typo in der Kopfzeile *** particleDiamenter *** ist nicht *** particleDiameter *** Es kann andere Probleme geben –