Algorithms/Find maximum/vb script method 1

<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>