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
Maximum of positive values
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Kirtan PatelRank #292 · 8.6K reputationPosted Mar 1, 2010, 1:02 AM EST
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 daniel189 reputationPosted Mar 1, 2010, 8:54 PM EST
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