hi

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

Example:
-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()
        dblArray.Add("-223.5")
        dblArray.Add("-78.9")
        dblArray.Add("-999.7")
        dblArray.Add("-456.7")

        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)
                    Else
                        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)
                    Else
                        holdMin = dblArray.Item(i2)
                        holdMax = holdMax
                    End If
                End If
            Next
        Next

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

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.