# Cool 1o2 Dimension Array Row Deleter Script

## Recommended Posts

Ever had a row in an array you wanted deleted? Well here is the script for you.

Func Name = delete_array_row

Variables:

\$array = name of your array

\$dimcount = dimensions of array (can be either 1 or 2)

\$row = row # you want deleted

```Dim \$array[10][2]

For \$i = 0 to UBound(\$array, 1) - 1
If \$i = 4 Then delete_array_row(\$array, 2, 5);line which deletes a row
MsgBox(1,"", \$array[\$i][1])
If \$i = UBound(\$array, 1) - 1 Then ExitLoop(1);exists loop if new end bounds is reached
Next

Func delete_array_row(ByRef \$array, \$dimcount, \$row)
If \$dimcount = 2 Then
Dim \$temp[UBound(\$array,1)-1][UBound(\$array,2)]
For \$a = 0 to \$row-1
For \$b = 0 to UBound(\$array,2) - 1
\$temp[\$a][\$b] = \$array[\$a][\$b]
Next
Next
For \$a = \$row+1 to UBound(\$array,1) - 1
For \$b = 0 to UBound(\$array,2) - 1
\$temp[\$a-1][\$b] = \$array[\$a][\$b]
Next
Next
\$array = \$temp
Return
Else
Dim \$temp[UBound(\$array,1) - 1]
For \$a = 0 to \$row-1
\$temp[\$a] = \$array[\$a]
Next
For \$a = \$row+1 to UBound(\$array,1) - 1
\$temp[\$a-1] = \$array[\$a]
Next
\$array = \$temp
Return
EndIf
EndFunc```

Don't forget the "If \$i = UBound(\$array, 1) - 1 Then ExitLoop(1)" line, because if you set the end of the For loop to the UBound of the array, that value is not "re-calculated" when you delete a row. So this line will factor that in. Suggestions welcome.

Edited by ozone

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...