hi friend
i need to find the maximum of negative value
for example
if 11,2,345,98,88 then
i need the value of 345
can anyone help me
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Kirtan PatelPosted Mar 1, 2010, 6:02 AM
MAX of Positive Values
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Array() As Integer = {11,2,345,98,88}
Dim max As Integer
max = Array(0)
For Each i As Integer In Array
If i > max Then
max = i
End If
Next
MsgBox("Max is :" & max)
End Sub
paul danielPosted Mar 2, 2010, 1:54 AM
Dim MaxIntegersIndex As Integer
Public Function MaxValOfIntArray(ByRef TheArray As Variant) As Integer
'This function gives max value of int array without sorting an array
Dim i As Integer
Dim MaxIntegersIndex As Integer
MaxIntegersIndex = 0
For i = 1 To UBound(TheArray)
If TheArray(i) > TheArray(MaxIntegersIndex) Then
MaxIntegersIndex = i
End If
Next
'index of max value is MaxValOfIntArray
MaxValOfIntArray = TheArray(MaxIntegersIndex)
End Function