继续加分,请教高人!!
For Alf0 = 0 To 70.8 * pi / 180 Step 0.1
f = 5836.4 * Sin(70.8 * pi / 180 - Alf0) - 741531.4 * Sin(Alf0) + r
If Abs(f) < 0.1 Then
h20 = (d0 + nx) * Sin(Alf0) - r
Text7.Text = Format(Alf0, "#.00")
Text8.Text = Format(h20, "#.00")
End If
Next Alf0
编译过去,但是没有结果显示在Text8.Text和Text7.Text
If Abs(f(Alf0)) < 0.001 Then
=====================================
这样不好..................
应该将值记录下来,最接近0的为最佳答案...例如:
dim temp as double
dim s as string
temp=999999999999999
For Alf0 = 0 To 70.8 Step 0.1
f(Alf0) = l0 * Sin(70.8 - Alf0) - (d0 + nx) * Sin(Alf0) + r
If Abs(f(Alf0)) < abs(temp) Then
s=cstr(alf0)&":"&cstr(f(alf0))
h20 = (d0 + nx) * Sin(Alf0) - r
Text7.Text = Format(Alf0, "#.00")
Text8.Text = Format(h20, "#.00"
End If
Next Alf0
debug.print s