Results 1 to 19 of 19

Thread: Unload hanging

  1. #1

    Thread Starter
    Frenzied Member Blobby's Avatar
    Join Date
    Oct 2001
    Location
    England
    Posts
    1,512

    Unload hanging

    Hello everybody peeps.

    has anyone found a way of stopping the PC hanging when you unload a form with over 20,000 rows in a listview? The more rows i have , the longer it takes to unload the app.

    6000 rows is about 4 seconds, 15000 rows, about 30 seconds and 25000 rows i may as well go for a pint! Any ideas on how to speed this up?

    Ta muchly
    There are 3 types of people in this world.........those that can count, and those that can't.

    Blobby

  2. #2
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    End.............................. could work...
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  3. #3
    Software Eng. Megatron's Avatar
    Join Date
    Mar 1999
    Location
    Canada
    Posts
    11,286
    Do you have any code that processes the listview items in the unload event?

  4. #4

  5. #5

    Thread Starter
    Frenzied Member Blobby's Avatar
    Join Date
    Oct 2001
    Location
    England
    Posts
    1,512
    Guys, I already have a listview.listitems.clear in the unload and i see the rows disappear from the screen as it happens but when it hits the unload................i have to wait for about 3 minutes while it recovers. Ill just have to restrict the rows returned.....sounds sensible anyway.
    There are 3 types of people in this world.........those that can count, and those that can't.

    Blobby

  6. #6

  7. #7

    Thread Starter
    Frenzied Member Blobby's Avatar
    Join Date
    Oct 2001
    Location
    England
    Posts
    1,512
    Sure, The Exit button does all the data unloading and i have no Unload sub. Heres the exit code:

    VB Code:
    1. Private Sub CommandExit_Click()
    2.     If CommandExit.Caption = "Exit" Then
    3.         Status = "Unloading data....please wait!"
    4.         Status.Refresh
    5.         MatchFiles.ListItems.Clear
    6.         Unload Me
    7.     Else
    8.         CancelSearch = True
    9.     End If
    10. End Sub
    There are 3 types of people in this world.........those that can count, and those that can't.

    Blobby

  8. #8
    PowerPoster
    Join Date
    Aug 2002
    Location
    NY, NY
    Posts
    2,139
    Here is my test: it takes fraction of a second to unload form with Listview having 20,000 items:
    VB Code:
    1. Option Explicit
    2.  
    3. Dim ITM As ListItem
    4. Dim LSI As ListSubItem
    5.  
    6. Private Sub Form_Load()
    7. Dim i&, j%
    8.  
    9.     With ListView1.ColumnHeaders
    10.         .Add , "LI", "List Item"
    11.         For j = 1 To 3
    12.             .Add , "SI" & j, "Sub Item " & j
    13.         Next j
    14.     End With
    15.     For i = 1 To 20000
    16.         Set ITM = ListView1.ListItems.Add(, , "Listitem " & i)
    17.         For j = 1 To 3
    18.             Set LSI = ITM.ListSubItems.Add(, "Subitem" & j, "Subitem " & j)
    19.         Next j
    20.     Next
    21.  
    22. End Sub
    23.  
    24. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    25.     ListView1.ListItems.Clear
    26. End Sub
    Roy

  9. #9

    Thread Starter
    Frenzied Member Blobby's Avatar
    Join Date
    Oct 2001
    Location
    England
    Posts
    1,512
    IROY55, fancy hearing from you

    Well the only difference i have in my code to you in yours is that i have 6 columns in my Listview and 28,000 rows....it takes about 1 and a half minutes to unload when i click exit. Ive moved the listitems.clear code to the query_unload event too.

    No idea what up with it. I can post u the whole code if u want to try it out on your pc. Its a windows explorer substitute when its finished.....not far to go with it, just the right click menu popup and the print results key to do.
    There are 3 types of people in this world.........those that can count, and those that can't.

    Blobby

  10. #10
    Hyperactive Member marnitzg's Avatar
    Join Date
    Oct 2000
    Location
    South Africa
    Posts
    372
    The problem is VB is doing housekeeping. You might want to change to a grid, or if you want to keep your listview, create a scrollbar to replace the listview one and store the data in your own variables/arrays.

  11. #11
    PowerPoster
    Join Date
    Aug 2002
    Location
    NY, NY
    Posts
    2,139
    No idea what up with it. I can post u the whole code if u want to try it out on your pc
    Sure, why not. Will be my pleasure.

    Cheers
    Roy

  12. #12

    Thread Starter
    Frenzied Member Blobby's Avatar
    Join Date
    Oct 2001
    Location
    England
    Posts
    1,512
    Marnitzg, thanks for the reply, i figured as much but wondered why IROY55 could exit with similar data and it not hang his app for 3 minutes!

    IROY55
    Hello chap, you have emails blocked from this board so cant send.
    There are 3 types of people in this world.........those that can count, and those that can't.

    Blobby

  13. #13
    PowerPoster
    Join Date
    Aug 2002
    Location
    NY, NY
    Posts
    2,139
    No personal emails, but why don't you post it here? Later ...
    Roy

  14. #14
    Hyperactive Member marnitzg's Avatar
    Join Date
    Oct 2000
    Location
    South Africa
    Posts
    372
    I had the same problem some time ago when I had to do maintenance on a database program that was only supposed to have +-100 records. The company then merged with another and boom suddenly there are 350000 products. I tell you it took about 20 minutes for the prog to load and about an hour to shut down.

    The time it takes to shut down is also dependent. Remember that the more columns you have, the more data is held. 20000 *3 = 60000 integers is not that much data. I'm not sure how a listview holds data but I would think it would be in variants. So if you have 20000 records of 15 character strings, thats quite a bit more data on its own, and thats only taking into account 1 column.

  15. #15

    Thread Starter
    Frenzied Member Blobby's Avatar
    Join Date
    Oct 2001
    Location
    England
    Posts
    1,512
    Yep i suppose so......ill just put a n unloading message on the screen or limit the amount of rows returned i think. No point in making the user think the apps crashed :/
    There are 3 types of people in this world.........those that can count, and those that can't.

    Blobby

  16. #16
    PowerPoster
    Join Date
    Aug 2002
    Location
    NY, NY
    Posts
    2,139
    Guys, despite Listview or perhaps Listbox may hold thousands of items, the question that comes to mind is "WHY DO YOU HAVE TO LOAD THIS MANY???". Why not considering to work with "chunks" of data whatever that could be (few hundred/thousand but definitely not 350,000 or so). Who's going to look through this many records anyway???
    Roy

  17. #17

    Thread Starter
    Frenzied Member Blobby's Avatar
    Join Date
    Oct 2001
    Location
    England
    Posts
    1,512
    A very good point IROY but you dont usually know how many rows you are going to retrieve from a search until the search is complete anyway and by that time you have loaded the rows into the table already. See, my app is like windows explorer and if you select a filename of * and choose all subdirectories, the app finds all files on your drive! My only option fortunately is to check the rowcount as i go and limit the amount of loaded rows to say 1000 (like the Windows explorer find option does).
    There are 3 types of people in this world.........those that can count, and those that can't.

    Blobby

  18. #18
    PowerPoster
    Join Date
    Aug 2002
    Location
    NY, NY
    Posts
    2,139
    but you dont usually know how many rows you are going to retrieve from a search until the search is complete
    You may create a stored proc on the server with in-parameters to limit your seach: parm will tell how many records to get. And after all it will be much faster anyway the any SQL statement you ever send.
    Roy

  19. #19
    Frenzied Member yrwyddfa's Avatar
    Join Date
    Aug 2001
    Location
    England
    Posts
    1,253
    I have to agree with IROY55: unless you are doing some form of administrative work there should be no way that your users can process/visualise or even contemplate more than about 100 records.

    Make the users search - this will cut down the record count.

    If you really must have this amount of records check out ADO's paging facility (it enables you to only to fetch pages based on cursor pointers)

    You could also load all of the items into an array (or some such structure) and only load the listview with the items that are currently being displayed (urgghh)

    I think that the design is at fault not the code - as the code looks fine to me

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