Click to See Complete Forum and Search --> : Need help replacing an item in a listbox
October 19th, 1999, 01:22 AM
I am really new at this...
I can not replace an item inside of a listbox with another item. It ony ends up going to the bottom. I'm sure it's probably pretty easy so any help would be great. Thanks
czimmerman
October 19th, 1999, 01:43 AM
GoTo http://www.freevbcode.com/ShowCode.Asp?ID=313. This is a function that allows you to find a string in a list box or combo box. Paste the code into your project. Then, use the function (called FindStringinListControl) as follows:
Dim lIndex as Long
lIndex = FindStringinListControl(List1, "SearchText")
If lIndex <> -1 then
List1.RemoveItem lIndex
List1.AddItem "Replacement Text", lIndex
End If
October 19th, 1999, 04:26 AM
I forgot to mention that I wouldn't know what to search for as this is user submitted text.. I need to know how to replace it using a line number..
Ravi Kiran
October 19th, 1999, 07:09 AM
Just say
Listbox.List(i) = "new string", where i is the 0-based (line)item no of the list box item. Wont this help?
RK
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.