Results 1 to 9 of 9

Thread: Comparing Numbers

  1. #1
    cmaroun2533
    Guest

    Comparing Numbers

    I am trying to compare a list of numbers in a list box and determine which are the highest or lowest. For example given a list of 50 numbers which are the lowest 25 numbers in the list. Does anyone have any idea on how to do this?

  2. #2
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536
    Format the numbers using the Format() function so that they all have the same nuumber of digits (left pad with leading zeroes).

    Use the Sorted property of the ListBox to display the entries in order.

    Retrieve the top or bottom 25 items from your list.

    Tris.
    This world is not my home. I'm just passing through.

  3. #3
    Bouncy Member darre1's Avatar
    Join Date
    May 2001
    Location
    Peterborough, UK
    Posts
    3,828
    since you can set a listboxs sorted property to True, (this will sort the list), then just select to top/bottom 25 etc
    Confucious say, "Man standing naked in biscuit barrel not necessarily ****ing crackers."

    Don't forget to format your code in your posts

  4. #4
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536
    Ah, just had a thought...

    Do you have duplicate numbers in your list?

    Tris.
    This world is not my home. I'm just passing through.

  5. #5
    Bouncy Member darre1's Avatar
    Join Date
    May 2001
    Location
    Peterborough, UK
    Posts
    3,828
    good point about the padding, forgot that

    that or you could stick em in an array and bubble sort them etc
    Confucious say, "Man standing naked in biscuit barrel not necessarily ****ing crackers."

    Don't forget to format your code in your posts

  6. #6
    cmaroun2533
    Guest
    yes there could possibly be duplicate numbers in the list

  7. #7
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536
    If you have duplicate numbers you will have to do what Darre1 and I already suggested, but instead of taking the first/last 25 entries you will need to code this.

    Code:
    count = 1
    a = first entry
    results( count ) = a
    
    while count < 25 do
        a = next entry
        if a <> results( count ) then
            count = count + 1
            results( count ) = a
        endif
    end while
    This world is not my home. I'm just passing through.

  8. #8
    cmaroun2533
    Guest
    you guys are awesome I appreciate the help

  9. #9
    Bouncy Member darre1's Avatar
    Join Date
    May 2001
    Location
    Peterborough, UK
    Posts
    3,828
    Originally posted by cmaroun2533
    you guys are awesome I appreciate the help
    trisglow and i will now go back to saving small worlds and stuff
    Confucious say, "Man standing naked in biscuit barrel not necessarily ****ing crackers."

    Don't forget to format your code in your posts

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