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

 Page 1 of 1 [ 4 post ]

Relevant Pages