vb一维数组怎么转换成二维数组??

ediex 2006-12-12 01:46:21
已知一维数组adcdatarray,每12个数字放到二维数组adata(i+12,j)一行中,怎么解决?
...全文
219 点赞 收藏 4
写回复
4 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
Dunzip 2006-12-12
理论上用CopyMemory要快些,但没有去测试。一测便知。

回复
ediex 2006-12-12
到底那个更快,我的数组 数据量比较大
回复
gguueesstt 2006-12-12

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)


Private Sub Form_Load()
Dim m As Long
Dim adcdatarray(1 To 12 * 6) As Long

For m = 1 To UBound(adcdatarray)
adcdatarray(m) = m
Next m

Dim adata(1 To 12, 1 To 6) As Long
CopyMemory adata(1, 1), adcdatarray(1), UBound(adcdatarray) * Len(adcdatarray(1))
Debug.Print adata(1, 1), adata(2, 1)
Debug.Print adata(1, 2), adata(2, 2)
End Sub
回复
tmd007 2006-12-12
Dim adcdatarray(20), adata(12, 10)
Private Sub Command1_Click()
Dim i, j
For i = 0 To 20: adcdatarray(i) = i: Next
For i = 0 To UBound(adcdatarray) Step 12
For j = 0 To 11
If j + i > UBound(adcdatarray) Then Exit For
adata(j, i \ 12) = adcdatarray(j + i)
Next
Next
For i = 0 To UBound(adcdatarray) \ 12
For j = 0 To 11
Print adata(j, i);
Next: Print
Next
End Sub
回复
发帖
VB基础类
创建于2007-09-28

7476

社区成员

VB 基础类
申请成为版主
帖子事件
创建了帖子
2006-12-12 01:46
社区公告
暂无公告