动态数组的注释是否对 .....学习中
请帮忙看看如此注释理解是否对:红色
Dim A() As Long
Private Sub Form_Click()
ReDim Preserve A(1 To 4) 'Preserve 可选的。关键字,当改变原有数组最末维的大小时,使 键字可以保持数组中原来的数据
A(1) = 1: A(2) = 2: A(3) = 3: A(4) = 4 '为动态数组A中元素赋值
Dim n As Long: n = 6 '需要插入的新数值
ReDim Preserve A(1 To 5)
Dim i As Long, m As Long '提供一个临时变量
For i = 2 To 5 '插入新数值
m = A(i) '当循环时把数组A(i)的值,放入临时变量 m, 腾出位置A(i),
把需要插入的新数值,赋给A(i),实现插入
A(i) = n
n = m '再令原来临时变量 m ,赋值给 n
Next i
For i = 1 To 5
Print Tab(4); "a(" & CStr(i) & ")=" & CStr(A(i)) '输出数组A中的元素
Next i
End Sub
谢谢