I use Lists a lot and discovered there were no built-in methods to Move an item from one index location to another index location, and there is no method to Swap two items.
ListMoveItem(List, FromIndex, ToIndex)
ListSwapItems(List, Index1, Index2)
ListMoveItem(List, FromIndex, ToIndex)
Purpose: Move an existing item to a different location in a List.
Example:
ListMoveItem(List1, 4, 1) 'Move item at index 4 to index 1
'Note: The item that was at index 1 will be at index 2 after the move completes.
Example:
ListMoveItem(List1, 4, 1) 'Move item at index 4 to index 1
'Note: The item that was at index 1 will be at index 2 after the move completes.
ListSwapItems(List, Index1, Index2)
Purpose: Swap the item at Index1 with the item at Index2 in List.
Example:
ListSwapItems(List, 4, 1) 'Swap the item at index 4 with the item at index 1
A sample program is included.Example:
ListSwapItems(List, 4, 1) 'Swap the item at index 4 with the item at index 1