DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2006
    Posts
    3

    listView .findItem when duplicates exist (Performance Issue the way it is coded)

    I have a listview that contains a checkbox, Div, UserID. I am using this to make a txt file of all the ones that are checked. The problem is that the listview contains around 100,000 entries which already takes about 7 seconds to load and I need to take the entries from the text file that are saved Div~UserID and search through the listview and check the ones that are already in the file.

    Here is how I am doing it now
    For j = 0 To intCounter - 1
    For i = 1 To .ListItems.Count
    .SelectedItem = .ListItems.Item(i)
    If .SelectedItem.ListSubItems(1) & "~" & .SelectedItem.ListSubItems(2) = varArray(j) Then
    .SelectedItem.Checked = True
    i = .ListItems.Count
    End If
    Next
    Next

    This is extremly slow being that it has to go through the entire listview until it finds the correct one.

    I was wanting to use the .finditem method but cant seem to get it to work when there are duplicates. It always just selects the first one and that is it. I did notice object.FindItem (string, value, index, match) and that index can supposly by a key. When I am loading the list I make the Key = Div~UserID but when I try to set the index = to that string for the key it gives a type mismatch. Even though it says the string is the value of the Key property for what the index is.

    Any ideas to help speed up performance?
    Thanks

  2. #2
    Join Date
    Nov 2003
    Location
    Alameda, CA
    Posts
    1,737
    The FindItem method works on the Text, or any SubItem, or the Tag property.
    I would assign the Tag property to Div~UserID, and then loop through (code not tested)


    dim index as long
    index = 1
    do
    set it = .FindItem(stringToFind, lvwTag, index)
    if it is nothing then exit do
    ---- do something with it here
    index = it.index + 1 '' start again from the next item
    set it = nothing
    loop
    "There are two ways to write error-free programs. Only the third one works."
    Unknown

Similar Threads

  1. They created J#, why couldn't they do VB#?
    By Thomas Eyde in forum .NET
    Replies: 290
    Last Post: 12-22-2001, 02:13 PM
  2. Performance issue
    By NewToSQL in forum VB Classic
    Replies: 1
    Last Post: 01-22-2001, 01:12 PM
  3. Replies: 2
    Last Post: 06-07-2000, 12:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links