Remove row from array & listbox

G

Guest

I have an array that I use to populate a listbox using the user defined
RowSourceType property. I want to have the ability to remove any item that
the user clicks on - Do I remove it from the listbox or remove it from the
array and repopulate the listbox - How is this accomplished through vba?

Thanks in advance for any assistance!

Jerry
 
T

Tim Ferguson

I have an array that I use to populate a listbox using the user
defined RowSourceType property. I want to have the ability to remove
any item that the user clicks on - Do I remove it from the listbox or
remove it from the array and repopulate the listbox - How is this
accomplished through vba?

I usually use the ValueList and then chop it up using Instr() and Mid$()
and so on. If you are using arrays already, you could also use Join() and
Split().

Hope that helps


Tim F
 
G

Guest

Tim,

I want to delete a row in the listbox that is populated from an array, the
number of rows can vary and once the row is deleted I need to re-populate the
listbox with the most current values. Should I delete the row in the listbox
or do I have to delete the row in the array and re-populate the listbox since
the array is the rowsource or do I do both.

How do I delete a row in the listbox or delete a row in an array?

Thanks,
Jerry
 
T

Tim Ferguson

How do I delete a row in the listbox or delete a row in an array?

quick and dirty method:

' get a copy of the value list
' need a semicolons at the end for the Replace function
' coming up next
sValueList = ";" & MyList.RowSource & ";"

' chop out the value.
sValueList = Replace(sValueList, ";" & uFindString & ";", ";")

' and reset the control
MyList.RowSource = Mid$(sValueList, 2, Len(sValueList)-2)
MyList.Requery

Deleting an element in an array can be hard or easy, depending on what
sort of sorting criteria you have. Consult any basic textbook on data
structures and algorithms.

Hope that helps



Tim F
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top