max / min value in a listbox 
Author Message
 max / min value in a listbox

Have a listbox with numbers being added to it one at a time from a click of
a button. The numbers are anywhere between 1-100. Let's say there are 5
numbers in the listbox 56, 78, 89, 99, 100. How could I find the max value
and min values in the listbox using code?

Thanks
Brian



Sun, 15 May 2005 17:55:03 GMT  
 max / min value in a listbox
Best way is a brute force solution - loop through all items and pull it out.
This code should do it.

dim o as object
dim iThis as integer
dim iBiggest as integer = -9999

for each o in ListBox1.Items
    iThis = cint(o)

    if iThis > iBiggest then
        iBiggest = iThis
    end if
next

debug.writeline("biggest item is " & iThis)


Quote:
> Have a listbox with numbers being added to it one at a time from a click
of
> a button. The numbers are anywhere between 1-100. Let's say there are 5
> numbers in the listbox 56, 78, 89, 99, 100. How could I find the max value
> and min values in the listbox using code?

> Thanks
> Brian



Sun, 15 May 2005 20:39:26 GMT  
 max / min value in a listbox
Make it sorted, and take the first and the last ?


Quote:
> Have a listbox with numbers being added to it one at a time from a click
of
> a button. The numbers are anywhere between 1-100. Let's say there are 5
> numbers in the listbox 56, 78, 89, 99, 100. How could I find the max value
> and min values in the listbox using code?

> Thanks
> Brian



Mon, 16 May 2005 06:29:13 GMT  
 max / min value in a listbox
Thanks Matt that works great


Quote:
> Best way is a brute force solution - loop through all items and pull it
out.
> This code should do it.

> dim o as object
> dim iThis as integer
> dim iBiggest as integer = -9999

> for each o in ListBox1.Items
>     iThis = cint(o)

>     if iThis > iBiggest then
>         iBiggest = iThis
>     end if
> next

> debug.writeline("biggest item is " & iThis)



> > Have a listbox with numbers being added to it one at a time from a click
> of
> > a button. The numbers are anywhere between 1-100. Let's say there are 5
> > numbers in the listbox 56, 78, 89, 99, 100. How could I find the max
value
> > and min values in the listbox using code?

> > Thanks
> > Brian



Thu, 19 May 2005 20:55:44 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Setting min and max values on chart's y-axis

2. Programming the min and max values of an axis

3. Returning max and min column values

4. Finding Max or Min Values - HELP!!!!

5. Scrollbar problem with min and max values

6. Max and Min values

7. Vertical slider Max/Min values...

8. Min & Max Values on Axis

9. Min and Max values of text field per page

10. Hot to get MAx and MIN value in a database

11. min and max

12. Keeping Access Open - System Modal Min/Max

 

 
Powered by phpBB® Forum Software