Question Get the lowest value from a listbox

Muchni

Member
Joined
Sep 30, 2008
Messages
18
Programming Experience
1-3
What I am trying to do is either:
1. I have some values in a listbox, and want to find the lowest
2. Convert all values to array, cant find what I did wrong here:
VB.NET:
     Dim allavarden() As Integer
        pop = 0
        Do Until pop = valuen.Items.Count - 1 'also tried with for loop and for each, neither worked


            allavarden(pop) = valuen.Items(pop) 'valuen = a listbox




        Loop


Please help
 
Last edited:
What I would do is use a For loop:
VB.NET:
Dim LowestInt As Integer = Integer.MaxValue
Dim LowestIndex As Integer = 0I
For Counter As Integer = 0I To valuen.Items.Count - 1I
  If CInt(valuen.Items(Counter)) < LowestInt Then
    LowestInt = CInt(valuen.Items(Counter))
    LowestIndex = Counter
  End If
Next Counter
'LowestIndex is the index of the item
'LowestInt is the lowest value
For starters
 
The zero is a number, the following 'I' tells the compiler that the number is explicitly an integer.
 
okey,ty, But the thing is that the values doesnt convert to integer, I used cint(x) to but if one value is 19999 and another is 59 then the lowest value is 19999.
 
So what values are in the ListBox? I was assuming Integer cause you were trying this using an Integer array.
 
nono, u were correct, it in number values in the listbox but somehow it doesnt converts to integer. I tried to use msgbox to find the problem and I think its something with the inxdex that doesnt change or something. It wont find the lowest tho
 
Back
Top