PDA

View Full Version : Array Help2



bjoshi
01-15-2012, 09:31 AM
Hi,

I just cant understand how arrays work, maybe a solution to the following might help.

(1) I need to declare 2 arrays (both should have size of 1)
(2) I will have a loop generating numbers (i) from 1 to 10.
(3) If i=odd then value will be added as an element to array1 and the size of array1 will increase by 1. (So now the array1 size should be 2)
(4) If i=even then value will be added as an element to array2 and the size of array2 will increase by 1. (So now the array size should be 2)
(5) After the loop finishes array1 will have the elements (1,3,5,7,9) and its size should be 6.
(6) After the loop finishes array2 will have the elements (2,4,6,8,10) and its size should be 6.
(7) Another loop should then be initiated which will test all elements in Array1 and remove them from the array1 if they are not divisible by 3. So Array1 at the end of the loop will have the elements (3,9) and a size of 2?

Phew....

Regards,
bjoshi

mdmackillop
01-15-2012, 09:40 AM
Sound like a homework project. Please refer to our FAQ.
Look at Redim Preserve to change array size.