Hello All,
I have the following piece of code that generates a runtime error 5: invalid call or argument error
Code:
Dim f as double
chMExpHg.Column = 2
For Z = 1 To (txtMExpT.Text * 60 / txtMExpRef.Text) + 1
chMExpHg.Row = Z
f = (txtMExpr0.Text * ((txtMExpA.Text * Exp(-0.693 * (Z - 1) * txtMExpRef.Text / 60 / txtMExpTd1.Text)) _
+ ((1 - txtMExpA.Text) * Exp(-0.693 * (Z - 1) * txtMExpRef.Text / 60 / txtMExpTd2.Text)) _
- (txtMExpB.Text * Exp(-0.693 * (Z - 1) * txtMExpRef.Text / 60 / txtMExpTi.Text)))) / pos_radiation(position)
chMExpHg.Data = -Log(f) / 0.122
Next Z
The error is generated on the line where the log of f is taken. I've been troubleshooting for quite some time and cannot find a solution.
I've printed out f during runtime and none of its values are negative or 0. Its first value is 0.0167 and the error is thrown on the first iteration of my loop.
Additionally, the error only occurs when the equation that sets f includes the part that starts with txtMExpB.Text is included (the user can enter either 0 or 1 into this textbox for this purpose at runtime).
Any ideas?
Thanks!