我在vb6中调试时正确的,不过你的这个定义可能不是你想要的
DIM A,B,C,D,E AS INTEGER
你这样定义的结果是ABCD都是double型,而e是整数型,在这个函数里刚好是没问题的,但我想你应该定义成这样:
dim a as integer,b as integer,d as integer,e as integer
dim c as double
ClS
a(2)=2
a(1)=1
b(2)=1
b(1)=1
a=2
b=1
for i=1 to 20 step 1
s=s+a/b
a(3)=a(1)
a(1)=a(2)
a(2)=a(2)+a(3)
b(3)=b(1)
b(1)=b(2)
b(2)=b(2)+b(3)
a=a(2)+a(1)
b=b(2)+b(1)
Next i
Print S
End
把b/a和c+(b/a)分开算,比如
e=b/a
c=c+e
就对了。
这样的问题我也经常遇到,目前原因未知,应该属于编程软件的bug吧.