CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Guest

    Need help replacing an item in a listbox

    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


  2. #2

    Re: Need help replacing an item in a listbox

    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





  3. #3
    Guest

    Re: Need help replacing an item in a listbox

    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..


  4. #4
    Join Date
    May 1999
    Location
    Omika, Japan
    Posts
    729

    Re: Need help replacing an item in a listbox

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured