[求助]如何调用变量来简化代码?
各位大侠:我是初学asp的新手,对代码不太熟,请高手指点下列代码如何简化?While NOT cgtj1.EOF
for i=1 to 8
if trim(cgtj1("年度"))=a(i,0) then
a(i,1)=cgtj1("数量")
a(9,1)=a(9,1)+a(i,1)
end if
next
cgtj1.MoveNext()
Wend
While NOT cgtj2.EOF
for i=1 to 8
if trim(cgtj2("年度"))=a(i,0) then
a(i,2)=cgtj2("数量")
a(9,2)=a(9,2)+a(i,2)
end if
next
cgtj2.MoveNext()
Wend
While NOT cgtj3.EOF
for i=1 to 8
if trim(cgtj3("年度"))=a(i,0) then
a(i,3)=cgtj3("数量")
a(9,3)=a(9,3)+a(i,3)
end if
next
cgtj3.MoveNext()
Wend
我想简化成:
for j=1 to 3
While NOT cgtj&j.EOF
for i=1 to 8
if trim(cgtj&j("年度"))=a(i,0) then
a(i,j)=cgtj&j("数量")
a(9,j)=a(9,j)+a(i,j)
end if
next
cgtj&j.MoveNext()
Wend
next
红色部分应该怎样写?我试了好久都不对,在这里先谢过高手指点。
[此贴子已经被作者于2007-9-5 15:33:58编辑过]