Use VB's Collections to build stacks and queues. Also included a safety wrapper for collections.
To operate as a stack/queue you do not need a separate key, everything is done using the index
This class adds new Methods and Properties to VB collections.
ArrayFromCollection Put contents of stack into an array
ArrayToCollection Load members of an array into the stack
Bottom: Returns first value added to stack
Clear: Empty stack in one call
Exists: Tests if index/Key is in stack. Uses error trap to test Optionally runs silent if error occurs
Extract: Remove any member from stack
Invert: Reverse order of stack
Max: Returns the highest alphanumeric member of stack
Middle: Returns Middle member of stack
Min: Returns the lowest alphanumeric member of stack.
Pop: Use collection as a LIFO (Last In First Out) stack, removes member from stack.
Pull: Use collection as a FIFO (First In First Out) stack, removes member from stack.
Push: Wrapper for VB standard Add. Push is used by both LIFO & FIFO stacks.
QuickSort: Sort stack into alphanumeric order
RandomMember: Extract a random member of the stack(Optional RemoveIt as Boolean = False); if True remove from stack
Replace: Change the Item for an Index/Key
Shuffle: Randomise the contents of the stack
Top: Returns last value added to array
I have also included a class ClsSafeCollection which wraps the standard collection in a safety net
Add: Modified to allow you to cope with the various error conditions that can occur
Count: VB standard Collection.Count
Item: Modified to allow you to cope with the 'Index/Key does not exist' error
Remove: Modified to allow you to cope with the 'Index/Key does not exist' error
Please comment and vote.
May just have reinvented the wheel for many of you but hope you find some use for it.
Feel free to use all or parts of this but leave copyrights in place and let me know about it at
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.Virus note:All files are scanned once-a-day by Planet Source Code for viruses, but new viruses come
out every day, so no prevention program can catch 100% of them. For your own safety, please:
- Re-scan downloaded files using your personal virus checker before using it.
- NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
- Scan the source code with Minnow's Project Scanner
If you don't have a virus scanner, you can get one at many places on the net
Other 48 submission(s) by this author
Report Bad Submission
Other User Comments
There are no comments on this submission.
Add Your Feedback
Your feedback will be posted below and an email sent to
the author. Please remember that the author was kind enough to
share this with you, so any criticisms must be stated politely, or they
will be deleted. (For feedback not related to this particular code, please
click here instead.)
To post feedback, first please login.