< Algorithms < Find maximum

<script type="text/vbscript">

   function findMax(aa)
      Dim o_intMax
      o_intMax = aa(0)
      for each p_intJ in aa
         if p_intJ > o_intMax then
             o_intMax = p_intJ
         end if
      next
      findMax = o_intMax
   end function    
   Dim cc(3)
   cc(0) = 3
   cc(1) = 6
   cc(2) = 5
   cc(3) = 1
   document.write("Max is " & findMax(cc) )    
 </script>

This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.