I have an array of X elements, and let’s say X = 50.
How do I remove every 5th element of the array?
Thus, the end result should be an array of only 40 elements left, since every 5th element was taken out….
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The code below isn’t tested but it should be pretty close, after the code has run all non divisible by 5 elements will be contained in array ‘strSecond’.
UPDATE
Code below has now been tested –
UPDATE II
This would work for a multi-dimensional array (only the upper bound of the last dimension in a multidimensional array can be changed when you use the Preserve keyword) –