06-03-2005, 05:36 PM
Ok, I need help finding out how to write the code for a label to show the minimum or maxiumum of the numbers in the list box. The list box has a list of temperatures in it; and the label needs to have the maxiumum temperature (corresponding label have the miniumum temperature). The number is a single, with 4 decimal places.
06-03-2005, 05:45 PM
Here is an example on how to find the lowest number,
Dim lowest As Single
Dim x As Integer
lowest = List1.List(0)
For x = 1 To List1.ListCount - 1
If List1.List(x) < lowest Then lowest = List1.List(x)
MsgBox "The Lowest Number = " & lowest
it cycles through each item in the list, and compares it to the lowest (or what it thinks is the lowest), if it finds an item that is lower, then it replaces the old value for the lowest with the new value.
this can be easily modified to find the highest.
06-03-2005, 07:00 PM
While the list entries are being added is a good time to track MinTemp and MaxTemp. Set MaxTemp to a tiny number and MinTemp to a very large number when the program starts. Then as each temp is added check and see if it is greater than Min or less than Max and store them as the new Min or Max. After the list is created, use the Format command to set the label captions.