Maximum Value - Help!

Results 1 to 2 of 2

Thread: Maximum Value - Help!

  1. #1
    Nick Forte Guest

    Default Maximum Value - Help!

    I&#039m trying to get the variable that has the maximum value. Let&#039s say:<BR>A = 3<BR>B = 4<BR>C =10<BR>D =1<BR><BR>These are dynamic, obviously, and I want to know how to retrieve which letter has the highest value. I was trying the UBound() function, but I was having difficulty, is there another easy way to do this??<BR><BR>Thanks.

  2. #2
    jason Guest

    Default RE: Maximum Value - Help!

    UBound only works with arrays, and returns the last element<BR>there&#039s no associative array structure in VBScript, which would make it easy.<BR><BR>the way i would do it would be to use JScript, and create an associative array. however i&#039m not sure if it&#039d work<BR><BR>var arr = new Array()<BR>arr[&#039a&#039] = 3<BR>arr[&#039b&#039] = 4<BR><BR>etc... you can then call sort, and get the highest value with array.sort()<BR><BR>but i&#039m not at all convinced that&#039ll work - but worth a try - fyi there&#039s an article on creating superarrays in JScript at - could be useful to you<BR><BR>jason

Posting Permissions

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