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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

re-add to an array from listbox

Status
Not open for further replies.

tchristo

Technical User
Aug 28, 2003
9
US
Hi all,

I've been able to get an array populated with a listbox in a form. But what I want to do is to keep adding to this array once the user has added more items to the listbox and clicked the "Add to Array" button again. I can't figure out how to store/remember the 1st set of items so that when the sub is called again (from clicking the button) it will just add the next set of items instead of creating a new array.

Any help would be great.

Below is what I have so far:

Public Sub cmdList_Click()

Dim arrLayers()
intCount = ListBox2.ListCount
ReDim arrLayers(intCount)

For i = 0 To ListBox2.ListCount - 1
strLayerName = ListBox2.List(i)
arrLayers(i) = strLayerName
Next i

End Sub

 
Two suggestions:

I assume you want to use arrLayers elsewhere so don't Dim it inside the Click event procedure. Declare it at the module level.

Take a look at ReDim Preserve in the Help file.


Regards,
Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top