liorim2
asked on
Keep array values when ReDimed
Lets say I have an array A(624, 9). it is already populated with values. How can i ReDim it to A(78, 78) and keep the original values (exactly the first 6241 values in A(624, 9), in the same order they appear when running from top to bottom, reading line by line in left to right order. This way, they are to form a square ReDimed array - A(78, 78) exactly filled with 6241 values taken orderly from the original A).
E. G.
original A = a b c d
e f g h
i j k l
m n o p
q r s t
u v w x
ReDimed A = a b c d e f
g h i j k l
m n o p q r
s t u v w x
many thanks.
E. G.
original A = a b c d
e f g h
i j k l
m n o p
q r s t
u v w x
ReDimed A = a b c d e f
g h i j k l
m n o p q r
s t u v w x
many thanks.
'Keeps values in A and adds 1 to size of the array
Redim Preserve A(Ubound(A) + 1)
A(Ubound(A)) = "NEWLY ADDED A!"
I am not sure that the preserve will work in this situation.
You can declare another array with B(6241). Populate all the values from A(624, 9) to B(6241) and then after the ReDim A(78, 78), you can copy B(6241) to A(78, 78).
You can declare another array with B(6241). Populate all the values from A(624, 9) to B(6241) and then after the ReDim A(78, 78), you can copy B(6241) to A(78, 78).
ASKER
William, you right. how do i copy B(6241) to A(78, 78)??
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
by the way 78 by 78 is smaller than 624 by 9, and neither is 6241
78 * 78 = 6084
624 * 9 = 5616
so how do you expect to keep the 'first 6241' values, when you don't have 6241 values in the first place?
AW
78 * 78 = 6084
624 * 9 = 5616
so how do you expect to keep the 'first 6241' values, when you don't have 6241 values in the first place?
AW
Hi AW / all,
An array of A(624, 9) holds 625*10 values being zero-relative (i.e. 0..624, 0..9 is 625 * 10).
PS. Further discussion regarding quick manipulation of array values using API calls:
https://www.experts-exchange.com/questions/20902787/Assign-a-range.html
Namely, the "RTLCopyMemory" function.
BFN,
fp.
An array of A(624, 9) holds 625*10 values being zero-relative (i.e. 0..624, 0..9 is 625 * 10).
PS. Further discussion regarding quick manipulation of array values using API calls:
https://www.experts-exchange.com/questions/20902787/Assign-a-range.html
Namely, the "RTLCopyMemory" function.
BFN,
fp.
ASKER
Arthur Wood, did you get fanpages's answer?
William, i dont know whats wrong with me today... IT IS THAT SIMPLE!! Anyway, you the man...
Million thanks.
Lior.
William, i dont know whats wrong with me today... IT IS THAT SIMPLE!! Anyway, you the man...
Million thanks.
Lior.
You're welcome Lior...
William.
William.
Redim Preserve YourArray(Size)
-Brian