Results 1 to 2 of 2

Thread: Help W/ Listview

  1. #1

    Thread Starter
    Member davethebrat's Avatar
    Join Date
    Jul 2001
    Location
    Buffalo, NY
    Posts
    51

    Help W/ Listview

    I made a web browser appliction that stores every web address thats navigated. I recently made a form with a listview control in it where you can choose a web address and delete it from the control. The problem is, i can't get it to delete muiltiple items which are checked off. I have tried this code below but it comes back as "index out of bounds." What am I doing wrong?

    dim i as integer
    With ListView1
    For i = .ListItems.Count - 1 To 0 Step -1
    If .ListItem(i).Selected Then .ListItem.Remove (i)
    Next
    End With

    Any suggestions/ideas on how to solve my problem?

  2. #2
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    Try this
    VB Code:
    1. Dim i As Long
    2.  
    3. With ListView1
    4.     For i = .ListItems.Count To 1 Step -1
    5.         If .ListItems(i).Selected = True Then .ListItems.Remove i
    6.     Next i
    7. End With
    Listview indexes appear not to be zero-based. Also you'd put ListItem a few times instead of ListItems, and also I changed the integer to a long because listviews are designed for almost limitless entries and Longs are faster to process anyway.

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