Vb Array element deletion. ????

Results 1 to 2 of 2

Thread: Vb Array element deletion. ????

  1. #1
    Join Date
    Dec 1969

    Default Vb Array element deletion. ????

    its there any easier way to delete a element completely from array in VbScript. i mean suppose i have 5 elements in array and i want to delete/remove the 3rd element from array so that only 4 elements are left.<BR><BR>Please help.<BR>

  2. #2
    Join Date
    Dec 1969

    Default Nope...arrays are *NOT* collections

    You could just put a NULL value into the 3rd element and then, when you use the array, skip all NULL elements.<BR><BR>Or you could use a loop to move all the higher numbered elements "down" and then resize the array:<BR> Sub DeleteElementByIndex( ByRef arr, ByValue index )<BR> Dim i<BR> For i = index To UBound(arr)-1<BR> arr(i) = arr(i+1)<BR> Next<BR> ReDim Preserve arr( UBound(arr)-1 )<BR> End Sub<BR> <BR>Needless to say, the above is a "costly" thing to do in terms of performance. Consider the skip-NULL-elements trick first, if possible.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts