Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

delete a row from a multidimensional array

Status
Not open for further replies.

sub5

Programmer
Oct 12, 2005
104
Hello All

I would like to code this principle, is it possible?
(I know how to do everything except delete a row from an array based on a criteria)

I would like to have a multidimensional array with field1 and field2. Say it is populated:

field1 field2
Joe bloggs
John smith

An SQL is then built pulling customer status from seperate tables.
The SQL is used as a row source in a combobox.
The cbobox dropdown lists:
Joe Bloggs Existing customer
John Smith new customer

The user selects Joe Bloggs and then fills in an unbound textbox with a region name and then clicks update. Joe Bloggs and the region are added as a record to a table.
AND
Joe Bloggs is removed from the array, the SQL is rebuilt so only John Smith appears in the combobox list.

Currently I append records to a temp table and use that table as the combobox rowsource. They are deleted using the combobox value as the criteria.

I am trying to get away from the temp table and the convoluted programming that goes into populating the temp table.

Any comments most welcome.
 
I do not think that you can really delete an item in an array. You could delete its value and refill the array to the new dimension. Thats normally how I have seen things "deleted" from an array. Why not just mark it as deleted? Another possibility depending on the size of this is to define a custom class and a custom collection. Then you can remove from the collection. Each property in the class could be one of your field values.
 
You can't exactly delete a row from an array, but you can ReDim and eliminate the last row

ReDim Preserve avar(0 to iCol, 0 to (UBound - 1))

If you want to delete other than the last row, then you will have to move the designated row to the end of the array. This is done by looping through each column in the row and swapping positions with the next row. This sounds as if it might be slow, but for a few thousand cells or less, you won't notice a delay.

Cheers,
Bill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top