Results 1 to 5 of 5

Thread: Max Element Of Array

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2001
    Posts
    1,374

    Max Element Of Array

    I need a function which, when passed a long array, returns the highest element.

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    You mean

    dim j as integer
    j = UBound(arrayname)
    debug.print arrayname(j)


    ?

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2001
    Posts
    1,374
    No. I meant the highest value not subscript. It's Ok. I found what I was looking for in a previous thread.

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    (Ned Flander's impression)
    Okilley Dokilley
    (/Ned FLander's impression)

  5. #5
    Member
    Join Date
    May 2002
    Posts
    40
    Try this function:

    Private Function MaxElement(a())
    el = LBound(a)
    Max = a(el)
    For i = LBound(a) To UBound(a)
    If a(i) > Max Then
    Max = a(i)
    el = i
    End If
    Next
    MaxElement = el
    End Function
    It's not working? Don't be discouraged. Try a bigger hammer!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width