下面是一個使用數組以表格顯示幾行幾列的簡單的示列代碼,希望對您有所協助。
<%
function tablebody(arr,cols,functionstr)
'arr為數組
'cols為列數
'functionstr為輸出內容用的function,沒有為空白
dim allnum,i,j
allnum = ubound(arr)
for i = 0 to (allnum/cols)
Response.write (VbTab &"<tr>" & VbNewLine)
for j = 0 to (cols-1)
ij = (i*cols+j)
Response.write (VbTab & VbTab &"<td width="""& formatnumber(100/cols,0) &"%"">")
if ij <= allnum then
if len(functionstr) > 0 then
execute(""& functionstr &"(arr(ij))")
else
Response.write (arr(ij))
end if
else
Response.write (" ")
end if
Response.write ("</td>" & VbNewLine)
next
Response.write (VbTab &"</tr>" & VbNewLine)
next
end function
function test1(str)
Response.write ("<div align=""center"">"& str &"</div>")
end function
'樣本1
dim kk(9)
for k = 0 to 9
kk(k) = k+1
next
%>
<table border="1" width="600" cellpadding="2">
<%call tablebody(kk,1,"")%>
</table>
<hr>