Dim myArray() As Integer = {a, b, c, d, f}

    Dim largest As Integer = Integer.MinValue
    Dim smallest As Integer = Integer.MaxValue

    For Each element As Integer In myArray
        largest = Math.Max(largest, element)
        smallest = Math.Min(smallest, element)
        'myArray(largest).Remove() 
    '(this part have error, as it stated that is not part of array statement)
    Next

    lblmax.Text = largest
    lblMin.Text = smallest

Based on the code above i would like to remove the largest and smallest element from the array list and then put it into a new array list, is it possible?
if yes please help out, thanks.

you need to pass the index of array element to remove. and in loop if u do it u will get error saying index out side the bounds of array, as element is deleted.

Dim myArray() As Integer = {a, b, c, d, f}

why do you have character in your integer arrary??

commented: eagle vision, nice. :D +10

you can do something like this:

Dim myArray() As Integer = {1, 4, 7, 9, 2, 3}

        Dim max As Integer = 0
        Dim min As Integer = Integer.MaxValue

        For Each i As Integer In myArray
            If i > max Then
                max = i
            End If

            If i < min Then
                min = i
            End If
        Next

        Label1.Text = "Max : " & max & " Min : " & min

        Dim minmaxArray() As Integer = {max, min}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.