#1
  1. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Nov 2012
    Posts
    1
    Rep Power
    0

    Question 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.


    Code:
    Private Sub btnengage_Click(sender As System.Object, e As System.EventArgs) Handles btnengage.Click
        lstResults.Items.Clear()
        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
            lstResults.Items.Add(lstStart.Items(i))
        Next
  2. #2
  3. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Mar 2012
    Location
    USA
    Posts
    75
    Rep Power
    0
    Try with this code to find min and max value.
    <code>
    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)
    End If
    If List1.List(i) < smll Then
    smll = List1.List(i)
    End If
    Next i
    Text1.Text = bg & " _ " & smll
    </code>
  4. #3
  5. No Profile Picture
    Registered User

    Join Date
    Nov 2013
    Posts
    1
    Rep Power
    0
    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..

Similar Threads

  1. Multiselect values in a listbox
    By cazlj in forum Microsoft Access Help
    Replies: 4
    Last Post: January 28th, 2005, 08:02 PM
  2. Replies: 1
    Last Post: August 5th, 2004, 12:44 PM
  3. Assigning textbox values to a listbox using VBA
    By sreddy013 in forum Microsoft Access Help
    Replies: 4
    Last Post: June 29th, 2004, 11:42 AM
  4. capture listbox values
    By Steve Schofield in forum ASP Development
    Replies: 1
    Last Post: September 20th, 2001, 11:58 AM
  5. Multiple values in a listbox
    By Steve Schofield in forum System Administration
    Replies: 0
    Last Post: September 13th, 2001, 05:29 PM

IMN logo majestic logo threadwatch logo seochat tools logo