VB里什么叫调用子过程?显示调用结果?利用自定义函数或子过程如何实现排序?

跪求帮忙!

dim a(10) as integer '定义全局数组

'主函数
sub mainfun()
'给数组赋值
dim i as integer
for i=0 to 10
a(i)=int(rnd*10) '赋值0-10的随机整数
debug.print a(i); '打印显示出来(排序前)
next
'调用子函数排序
call paixu(a)
print '换行
for i=0 to 10
debug.print a(i); '打印显示出来(排序后 即调用结果)
next
print '换行
end sub

'自定义函数(排序)
function paixu(a)
dim j1 as integer, j2 as integer
dim temp as integer
for j1=0 to ubound(a)-1
for j2=j1+1 to ubound(a)
if a(j1)>a(j2) then
temp =a(j1)
a(j1)=a(j2)
a(j2)=temp
end if
next
next
end function
温馨提示:答案为网友推荐,仅供参考
相似回答