冒泡法能做成一MODULE,然后被FROM调用吗
FROM中 有个数组, 要根据不同参数,调用好多个最值,想做一个冒泡法的模块
Public Sub OpenMaopao1()
Dim iter, N As Integer
Dim Counter, Counter1 As Integer
For iter = 1 To lc_num
For Counter = iter To lc_num
If zuizhi(iter - 1, T1) < zuizhi(Counter, T1) Then '对二维数组 zuizhi(i, j)排序,挑出最大配筋工况
For Counter1 = 1 To 8
temp(0, Counter1 - 1) = zuizhi(iter - 1, Counter1 - 1)
zuizhi(iter - 1, Counter1 - 1) = zuizhi(Counter, Counter1 - 1)
zuizhi(Counter, Counter1 - 1) = temp(0, Counter1 - 1)
For N = 0 To 8
temp(0, 8) = 0
Next
Next
End If
Next
Next
End Sub
在 FROM中Dim zuizhi(100, 30)为全局变量但是程序认为zuizhi 未定义 ,,
[解决办法]
用参数传递,如Public Sub OpenMaopao1( zuizhi() as double)
调用:call OpenMaopao1(zuizhi)
[解决办法]
如果涉及到不同数组名称, 不同数组长度, 不同数据类型的话, 可以把参数写成数组地址, 数据类型和长度
然后在模块内用模拟指针的方式获取数组内容, 排完序再放回去.
不过,只是个冒泡法, 费这么大力气有点不值得.