-
Mar 26th, 2017, 08:58 PM
#1
Thread Starter
Addicted Member
How possible Redim Preserve Array In Array
Hi,
is the simply way redim array in another array?
My code
Code:
Dim arrx(1)
arrx(0) = Array(0)
arrx(1) = Array(0)
how possible redim preserve only array in dimension 1?
Something like this
Code:
Redim Preserve arrx(1)(10)
?
Ten Years After - 01 You Give Me Loving
-
Mar 26th, 2017, 09:27 PM
#2
Re: How possible Redim Preserve Array In Array
Something like:
Code:
Dim A(1) As Variant
Dim Temp As Variant
A(0) = Array(0)
A(1) = Array(0)
Temp = A(1)
ReDim Preserve Temp(10)
A(1) = Temp
Temp = Empty
-
Mar 27th, 2017, 12:31 AM
#3
Thread Starter
Addicted Member
Re: How possible Redim Preserve Array In Array
Working, but only in 1-d dimension. If 2d
Code:
ReDim Preserve Temp(1, 10)
isn't working...
Ten Years After - 01 You Give Me Loving
-
Mar 27th, 2017, 02:56 AM
#4
Re: How possible Redim Preserve Array In Array
Can you explain what you need or want to do?
-
Mar 27th, 2017, 11:39 AM
#5
Thread Starter
Addicted Member
Re: How possible Redim Preserve Array In Array
I want gathering data from dynamic list
Code:
Level, Name
3 name1
4 name2
1 name3
3 name4
1 name5
2 name6
2 name7
4 name8
...
and then show only top 10 by level. And I want iterate four arrays (1 to 4) from first with min values to last array with max values, while 10 records is shows.
Ten Years After - 01 You Give Me Loving
-
Mar 27th, 2017, 02:50 PM
#6
Re: How possible Redim Preserve Array In Array
Pass the low-level array as an argument and then redim.
Code:
Option Explicit
Private Sub Form_Load()
Dim arrx(1)
arrx(0) = Array(0)
arrx(1) = Array(0)
DoRedim arrx(0), 10
MsgBox UBound(arrx(0)) ' Reports 10, which is correct.
MsgBox UBound(arrx(1)) ' Reports 0, which is correct.
End Sub
Sub DoRedim(TheArray As Variant, NewUpperBound As Long)
ReDim Preserve TheArray(LBound(TheArray) To NewUpperBound)
End Sub
Enjoy,
Elroy
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.
-
Mar 27th, 2017, 04:39 PM
#7
Re: How possible Redim Preserve Array In Array
Another option using UDTs, just because...
Code:
Private Type ArrayCont
A() As Variant ' or long, byte, whatever
Z() As Variant ' or long, byte, whatever
End Type
Private Sub Form_Load()
Dim ac As ArrayCont
ReDim ac.A(0 to 4)
ReDim ac.Z(0 to 4)
ac.A(2) = "Hello World"
ReDim Preserve ac.A(0 to 9)
MsgBox ac.A(2)
Unload Me
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|