Link to home
Start Free TrialLog in
Avatar of Jesus112398
Jesus112398

asked on

Manipulating Arrays

Please could someone offer the shortest code to do the following:

Delete an element in the middle of a dynamic array meaning all the elements above that one in the set are pushed down one.

Test whether a variable equals that of an element in an array.


Thanks
Avatar of atelford
atelford

It would be mouch easier if you used a collection , then you would have no need to resize the array after a delete , but thats just my opinion
ASKER CERTIFIED SOLUTION
Avatar of CesarGon
CesarGon
Flag of Spain image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Comments to the proposed answer:
Redim will clear the contents of the array and you will lose the values of all the elements.  You have to use keyword PRESERVE to keep the contents of the elements:

ReDim preserve a(1 To 9) As String

Good luck

Of course you have to use Preserve!. I forgot writing it in my code. Sorry about my mistake and thanks for pointing it out.