Results 1 to 10 of 10

Thread: sorting a list box

  1. #1

    Thread Starter
    Hyperactive Member Filter300's Avatar
    Join Date
    Aug 2001
    Posts
    413

    sorting a list box

    i have a list box that i need to sort in decending order.. and when i check the sorted proporty it just does it in acending... is there anyway to set this to decending? or do ihave to write my own sort for this?

  2. #2
    Frenzied Member seoptimizer2001's Avatar
    Join Date
    Apr 2001
    Location
    Toledo, Ohio USA GMT -5
    Posts
    1,075
    You could let the listbox sort it for you then put the items in an array and change the sorted property to false and input the array back in reverse order. Then you wouldn't have to deal with doing the actual sorting.
    seoptimizer2001
    VB 6.0, VC++, VI, ASP, JavaScript, HTML,
    Perl, XML, SQL Server 2000

    If God had intended us to drink beer, He would have given us stomachs.


    Please use the [code] and [vbcode] tags in your posts!
    If you don't know how to use them please go HERE!


  3. #3

    Thread Starter
    Hyperactive Member Filter300's Avatar
    Join Date
    Aug 2001
    Posts
    413
    hey thats kewl.. its almost too easy.. thanks for the help...

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    If you are populating your Listbox from a recordset, the easiest way is to sort the recordset at creation time by doing an ORDER BY, set the Listbox Sorted property to False, and dump the results in your Listbox.

  5. #5

    Thread Starter
    Hyperactive Member Filter300's Avatar
    Join Date
    Aug 2001
    Posts
    413
    i'm not useing a record set.. this is a PDF retreval program.. it scans across all of our servers serching for pdf files that contain the specified account number in the name.. and i need to have PDF files sorted in decending order in the list box so they see the newest pdf's first.. now i got a new question.. i'm useing the item data to hold the key to an array that stores the address of the pdfs... cuz i only show the user just the name of it.. how do i keep my itemdata accurate??

  6. #6
    Frenzied Member seoptimizer2001's Avatar
    Join Date
    Apr 2001
    Location
    Toledo, Ohio USA GMT -5
    Posts
    1,075
    The new key to the array will be Ubound(YourArray) - original key.
    seoptimizer2001
    VB 6.0, VC++, VI, ASP, JavaScript, HTML,
    Perl, XML, SQL Server 2000

    If God had intended us to drink beer, He would have given us stomachs.


    Please use the [code] and [vbcode] tags in your posts!
    If you don't know how to use them please go HERE!


  7. #7

    Thread Starter
    Hyperactive Member Filter300's Avatar
    Join Date
    Aug 2001
    Posts
    413
    yep... i must be dense today.. sorry for being an idoit... thanks for the help!!

  8. #8

    Thread Starter
    Hyperactive Member Filter300's Avatar
    Join Date
    Aug 2001
    Posts
    413
    List1.Sorted = True
    says i cant assign to a read only property... any other way to do this?

  9. #9
    Frenzied Member seoptimizer2001's Avatar
    Join Date
    Apr 2001
    Location
    Toledo, Ohio USA GMT -5
    Posts
    1,075
    Have 2 Listboxes in the same place and use an invisible one to sort that has a sorted = true and another visible one that is set to Sorted = False, but you sort.
    seoptimizer2001
    VB 6.0, VC++, VI, ASP, JavaScript, HTML,
    Perl, XML, SQL Server 2000

    If God had intended us to drink beer, He would have given us stomachs.


    Please use the [code] and [vbcode] tags in your posts!
    If you don't know how to use them please go HERE!


  10. #10

    Thread Starter
    Hyperactive Member Filter300's Avatar
    Join Date
    Aug 2001
    Posts
    413
    yeah thats what i'm working on right now.. just tring to copy the itemdata to the new list box..

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