Array question

atkin

New member
Joined
Mar 12, 2007
Messages
2
Programming Experience
Beginner
I have made a simple drawing program and want to offer the user an 'undo' button so the last item they draw is undone, i intend to do this by taking the array (dynamic list array) back an item. what is the code to do this, i looked at using form.arrayname.item(-1) but wasnt sure how to implement it, any help would be appriated.
 
what you would probably want to do is, take the last item in the array and remove it from the array (when you remove it from the array, that's where you have the code to actually undo the item in your program)

I would also suggest using an arraylist for this too, it'll be easier to add and remove items from the array, using the Add method and the Remove(array.Count) method
 
You have to call redim, don't forget preserve if you want to keep the values. You can user GetUpperBound(0) to remove the last item, GetLowerBound(1) to remove the first item.

ReDim Preserve YourArray(YourArray.GetUpperBound(0) - 1)
 
Back
Top