趋势线方程评估变量值不在循环中更新

时间:2016-04-05 18:25:55

标签: excel excel-vba vba

我正在编写一个程序,该程序将采用两条趋势线交叉并继续评估它们,直到找到一个可接受地接近交叉点的点。

我已经达到了趋势线的程度,格式化了我喜欢的格式,并且我已经用变量(数组的一列)替换了x' s。当我开始循环时,有100个输入,其中最低的是我的"点",在评估趋势线方程之前,变量不会更新为新值或步骤

这是我的代码的相关部分,其中tl1eq和tl2eq是我的趋势线方程字符串:

tl1eq = Replace(tl1eq, "y =", "")
tl1eq = Replace(tl1eq, "x2", "x^2")
tl1eq = Replace(tl1eq, "x", " * " & flhd(i, 1) & " ")

tl2eq = Replace(tl2eq, "y =", "")
tl2eq = Replace(tl2eq, "x6", "x^6")
tl2eq = Replace(tl2eq, "x5", "x^5")
tl2eq = Replace(tl2eq, "x4", "x^4")
tl2eq = Replace(tl2eq, "x3", "x^3")
tl2eq = Replace(tl2eq, "x2", "x^2")
tl2eq = Replace(tl2eq, "x", " * " & flhd(i, 1) & " ")

'create an step amount between low and high flows, with 100 steps
x = (hflow - lflow) / 100

'fill array with step values and summation of curve equations
For i = 1 To 100
    flhd(i, 1) = lflow + (x * i)
    flhd(i, 2) = Abs(Evaluate(tl1eq) - Evaluate(tl2eq))
    MsgBox (flhd(i, 1) & " " & tl1eq & " " & Evaluate(tl1eq) & " " & tl2eq & " " & Evaluate(tl2eq))
Next i

flhd(i,1)在评估时不会在字符串中更新,但在msgbox中它会将其显示为正确的值。

任何帮助都将不胜感激。

0 个答案:

没有答案