一个循环问题
假如我代码是这样的:
If page = 1 then
Message(1) = "&H " & combo1(0).ListIndex
Message(2) = "&H " & combo2(0).ListIndex
Message(3) = "&H " & combo3(0).ListIndex
Message(4) = "&H " & combo4(0).ListIndex
Message(5) = "&H " & combo5(0).ListIndex
Message(6) = "&H " & combo6(0).ListIndex
ElseIf page = 2 then
Message(1) = "&H " & combo1(0).ListIndex
Message(2) = "&H " & combo2(0).ListIndex
Message(3) = "&H " & combo3(0).ListIndex
Message(4) = "&H " & combo4(0).ListIndex
Message(5) = "&H " & combo5(0).ListIndex
Message(6) = "&H " & combo6(0).ListIndex
Message(7) = "&H " & combo1(1).ListIndex
Message(8) = "&H " & combo2(1).ListIndex
Message(9) = "&H " & combo3(1).ListIndex
Message(10) = "&H " & combo4(1).ListIndex
Message(11) = "&H " & combo5(1).ListIndex
Message(12) = "&H " & combo6(1).ListIndex
ElseIf page = 3 then
Message(1) = "&H " & combo1(0).ListIndex
Message(2) = "&H " & combo2(0).ListIndex
Message(3) = "&H " & combo3(0).ListIndex
Message(4) = "&H " & combo4(0).ListIndex
Message(5) = "&H " & combo5(0).ListIndex
Message(6) = "&H " & combo6(0).ListIndex
Message(7) = "&H " & combo1(1).ListIndex
Message(8) = "&H " & combo2(1).ListIndex
Message(9) = "&H " & combo3(1).ListIndex
Message(10) = "&H " & combo4(1).ListIndex
Message(11) = "&H " & combo5(1).ListIndex
Message(12) = "&H " & combo6(1).ListIndex
Message(13) = "&H " & combo1(2).ListIndex
Message(14) = "&H " & combo2(2).ListIndex
Message(15) = "&H " & combo3(2).ListIndex
Message(16) = "&H " & combo4(2).ListIndex
Message(17) = "&H " & combo5(2).ListIndex
Message(18) = "&H " & combo6(2).ListIndex
ElseIf page = 4 then
...
ElseIf page = 150 then
End If
请教高手,如果这样写肯定是个愚蠢的方法,要如何写一个循环表示上面的意思?如果分少了以后再加,现在没分了,谢谢!
[解决办法]
for i=0 to page-1
Message(i*6+1) = "&H " & combo1(i).ListIndex
Message(i*6+2) = "&H " & combo2(i).ListIndex
Message(i*6+3) = "&H " & combo3(i).ListIndex
Message(i*6+4) = "&H " & combo4(i).ListIndex
Message(i*6+5) = "&H " & combo5(i).ListIndex
Message(i*6+6) = "&H " & combo6(i).ListIndex
next