Option ExplicitPrivate Sub Command1_Click() Dim a(4) As Integer a(0) = 1 a(1) = 3 a(2) = 5 a(3) = 7 a(4) = 11 Dim b() As Integer ReDim b(0) Dim i As Integer Dim j As Integer For i = 0 To 4 ReDim Preserve b(j) b(j) = a(i) If a(i) <= 5 Then ReDim Preserve b(j + 1) b(j + 1) = a(i) + 10 j = j + 1 End If j = j + 1 Next Dim str As StringFor i = 0 To UBound(b) str = str & "b[" & i & "] = " & b(i) & vbCrLf Next MsgBox str End Sub
http://community.csdn.net/Expert/topic/4646/4646935.xml?temp=.6282007
Dim a(4) As Integer
a(0) = 1
a(1) = 3
a(2) = 5
a(3) = 7
a(4) = 11
Dim b() As Integer
ReDim b(0)
Dim i As Integer
Dim j As Integer
For i = 0 To 4
ReDim Preserve b(j)
b(j) = a(i)
If a(i) <= 5 Then
ReDim Preserve b(j + 1)
b(j + 1) = a(i) + 10
j = j + 1
End If
j = j + 1
Next
Dim str As StringFor i = 0 To UBound(b)
str = str & "b[" & i & "] = " & b(i) & vbCrLf
Next
MsgBox str
End Sub