测试了一下, Form_Load过程耗时大概是1秒多一点1.2秒左右(包括加载界面与运行通用过程),Command1_ClIck过程耗时不到1秒,在40-150毫秒之间,因此根本谈不上“很耗时间”!
程序代码:
Dim B1(0 To 10, 0 To 1000, 0 To 1000) As String, B2(0 To 5, 0 To 800, 0 To 800) As String
Private Sub Command1_ClIck()
Dim I As Integer, J As Integer
For I = 0 To 800
For J = 0 To 800
B1(0, I, J) = B2(0, I, J)
B1(2, I, J) = B2(2, I, J)
B1(1, I, J) = B2(1, I, J)
Next J
Next I
End Sub
Private Sub Form_Load()
Dim I As Integer, J As Integer, X As Integer
For X = 0 To 5
For I = 0 To 800
For J = 0 To 800
Randomize
B2(X, I, J) = CStr(Int(Rnd * 90 + 100))
Next J
Next I
Next X
End Sub
在VB中,赋值是最快的,如果使用数组拷贝恐怕耗时要慢得多,因为需要一个一个读取数组地址,解压还是使用赋值比较好。