November 30th, 2012, 09:32 PM
How to find the min and max values from a listbox using an if block?
The list box is pre-populated, I need to find the count, reverse the order which I have done, but the last part is to find the min and max numbers from the list. Ive drawn a blank.
Private Sub btnengage_Click(sender As System.Object, e As System.EventArgs) Handles btnengage.Click
Dim n As Integer = lstStart.Items.Count
Dim min As Integer = lstStart.Items.Item(0)
Dim max As Integer = lstStart.Items.Item(lstStart.Items.Count - 1)
txtcount.Text = (lstStart.Items.Count)
For i As Integer = (n - 1) To (n - txtcount.Text) Step -1
April 23rd, 2013, 08:05 AM
Try with this code to find min and max value.
i = 0
Dim bg As Integer
Dim smll As Integer
bg = 0
smll = 0
For i = 0 To List1.ListCount - 1
If List1.List(i) > bg Then
bg = List1.List(i)
If List1.List(i) < smll Then
smll = List1.List(i)
Text1.Text = bg & " _ " & smll
November 19th, 2013, 01:14 AM
The post was absolutely fantastic! Great deal of great information and this can be attractive some and the other way. Keep updating your post,excited to get more detailed contents…Great job, thanks..