i want code in VB.net 2008 or 2005 to find Max for negative value ??? also this function can find max for positive value

-223.5 , -456.7 , - 999.7 , -78.9

Max= -78.9

please help me :(

OK, you didn't say how you got those values, so I just added them to an arraylist during form_load event. My code is a little backwards, but it works for me, lol.

Dim dblArray As New ArrayList()

        Dim holdMin As String = ""
        Dim holdMax As String = ""

        'get max & min
        For i = 0 To dblArray.Count - 1
            For i2 = 1 To dblArray.Count - 1
                If dblArray.Item(i) > dblArray.Item(i2) Then
                    If dblArray.Item(i) > holdMax Then
                        holdMax = dblArray.Item(i)
                        holdMin = dblArray.Item(i2)
                        holdMax = dblArray.Item(i2)
                        holdMin = holdMin
                    End If
                ElseIf dblArray.Item(i) < dblArray.Item(i2) Then
                    If dblArray.Item(i) < holdMin Then
                        holdMin = dblArray.Item(i)
                        holdMax = dblArray.Item(i2)
                        holdMin = dblArray.Item(i2)
                        holdMax = holdMax
                    End If
                End If

'this is the minimum value for some reason :P
        TextBox2.Text = holdMax
'this is the maximum value for some reason :P
        TextBox3.Text = holdMin

The max and min values are backwards for me, but it works, sometimes, lol. See if that helps any. It's not perfect but should help you out some.

hi crazyhorse09

thanks you help me in my project

thanks so much.....

This article has been dead for over six months. Start a new discussion instead.