VBScript Array Functions – DeleteFromArray, InArray

VBScript has a infamously weak implementation of array capabilities. There often comes situations where you’d like to manipulate an array and VBScript just doesn’t have the functionality built in natively.

One of the things that I need to do frequently is delete a value from an array. Well to do this you have too loop through the array and rebuild it as a new array. Since this is such a common task I wrote a little function to do it for me.

Other times I’d simply like to know if an array has a certain value within it. So I can add or remove it or simply act upon it. Well I wrote another one for that too called InArray. It will return a boolean letting you know if the string you are checking for exists within the array.

I will probably add to this later, if anyone has suggestions for additions to this please feel free to forward or submit your code. I’ll almost certainly add sorting code to this later, even though there is a dictionary object available to do that now from VBScript natively.


3 thoughts on “VBScript Array Functions – DeleteFromArray, InArray”

  1. Hello Nathan :

    First of all Thank you for these very helpful Array functions that I found searching the topic over the Internet.

    Regarding the First function DeleteFromArray(aArray, vElementNumber) it seems that a consistent error is thrown if you launch the Function to remove the 0 Index element eg DeleteFromArray(aArray, 0).

    Thanks Again

  2. Hello Nathan : I did not find one .. 🙁

    So to solve my “own” issue I had to come up with a very cumbersome workaround (iterating trough a phony duplication of my original array to mark the items to be deleted and then a Redim of my Original array inserting only the items to be kept).

    I doubt that anybody will ever want to do this .. but it took care of things for me..


Leave a Comment