Algorithms/Find maximum/visual basic method 1

From Wikibooks, open books for an open world
Jump to navigation Jump to search
Function FindMax(ByVal x() As Integer) As Integer
        If x.Length = 0 Then
            Return 0
        ElseIf x.Length = 1 Then
            Return x(0)
            Dim temp As Integer = x(0)

            For i As Integer = 0 To x.Length - 1
                If x(i) > temp Then
                    temp = x(i)
                End If
            Return temp
        End If
End Function