Notices

Great community. Great ideas.

Welcome to ASP/Free, a community dedicated to helping beginners and professionals alike in improving their knowledge of Microsoft's development and administration technologies. Sign up today to gain access to the combined insight of tens of thousands of members.

Thread: How to find the min and max values from a listbox using an if block?

Results 1 to 3 of 3
Share This Thread →
  1. #1
    CCoogan is offline Registered User
    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
    annaharris is offline Registered User
    Join Date
    Mar 2012
    Location
    USA
    Posts
    76
    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>

  3. #3
    Aaida45 is offline 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..

Share This Thread →

Become Part of This Conversation

Join NowFor Free!

Similar Threads

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

ASP Free Advertisers and Affiliates