VBA中如何把两个FOR…NEXT循环嵌套的内容都放在一个一维数组中?
3个回答
展开全部
Private Sub CommandButton1_Click()
Dim iarr(5) As String
Dim jarr(10) As String
Dim arr() As String
ReDim Preserve arr(0)
Dim i, j As Integer
Dim m As Integer: m = 0
For i = 0 To UBound(iarr)
ReDim Preserve arr(UBound(arr) + 1)
arr(m) = iarr(i)
m = m + 1
Next i
For j = 0 To UBound(jarr)
ReDim Preserve arr(UBound(arr) + 1)
arr(m) = jarr(j)
m = m + 1
Next j
End Sub
这段代码提供一个思考的方向或者说是模型,仅供参考
展开全部
for i=0 to 5
for j=5 to 10
if i<5 then
a(x)=i
else
a(x)=j
endif
x=x+1
next
next
for j=5 to 10
if i<5 then
a(x)=i
else
a(x)=j
endif
x=x+1
next
next
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询