dim num as integer
num = ubound(arrcontrol)
for i = 0 to num
for j = i + 1 to ubound(arrcontrol)
if arrcontrol(i).tabindex > arrcontrol(j).tabindex then
set temp = arrcontrol(i)
set arrcontrol(i) = arrcontrol(j)
set arrcontrol(j) = temp
end if
next j
next i
end sub
public sub arraytagproc(arr() as control) '对控件的<.tag>属性进行排序
'越在屏幕上面的控件,其<.top>值越小,故让其<.tag>值也小(最综的目的是让其索引值小)
dim i as integer, j as integer
dim temp as variant
dim num as integer
dim arrtop() as integer '存储控件<.top属性>数组
num = ubound(arr)
redim arrtop(num)
for i = 0 to num
arrtop(i) = arr(i).top
next
sortproc arrtop '按照由小到大顺序
for i = 0 to num
for j = 0 to num
if arr(i).top = arrtop(j) then arr(i).tag = j
next j
next i
end sub
以上程序在vb5.0、vb6.0中调试通过。读者可以用到自己的程序中,今后再也不用为调整位置和索引顺序而作一些简单重复劳动了。