Maximum Value in Array

# Thread: Maximum Value in Array

1. Junior Member
Join Date
Dec 1969
Posts
16

## Maximum Value in Array

ok, pros. I have a huge amount of questions, but I think i&#039;ll start with the one that is conserning my mind at the moment, and preventing me from getting my deeds done.<BR><BR>Well, 1st I have to apologise if this same Q has been asked resently, I just registered my self (as there is no answer to my Q in whole Google DB) and if you can help me out, you have one regular user more ;) Try to hang on with my lowsy spelling, I&#039;m foreigner ;o) And with all that said, I&#039;ll go &#039;n get on cup of coffee and start the issue..<BR><BR><BR><BR>I&#039;m new in ASP world. I started coding at last spring. But I think I have learned pretty fast, the language is logical and easy to learn. Well, I just discovered Arrays. I used to loop through recordset with while not EOF etc, dirty way - as I think now, as the GetRows() is a lot faster. Enough babbling already - to the Q:<BR><BR>Let&#039;s imagine that I create an 2D array dynamically:<BR><BR>vVisData = CDat.GetRows()<BR>LoopNro = UBound(vVisData,2)<BR>Dim aThread()<BR>ReDim aThread(n,LoopNro)<BR>For x = 0 To LoopNro<BR> aThread(1,x) = vVisData(1,x) &#039; Post ID<BR>Next<BR><BR>Now I have an array that contains values of all the "Post ID&#039;s" in the recordset. Imagine, that those values may vary randomly, like: 0=1,1=2,2=0,3=1,4=1,etc...<BR><BR>Is there a way to get the maximum value of the array? If you&#039;re kind enough, please give me an example.<BR><BR>cheers,<BR> - Vic

2. Senior Member
Join Date
Dec 1969
Posts
7,686

## RE: Maximum Value in Array

The only way is to loop through the array and check each value.

3. Senior Member
Join Date
Dec 1969
Posts
999

## or....

sort the array on a particular dimension (look for bubble sort algorithm on google) and select the first entry in the array

4. Senior Member
Join Date
Dec 1969
Posts
999

## here's a sort algorithm....

5. Junior Member
Join Date
Dec 1969
Posts
16

## Thanks

Thank you both.<BR><BR>You have now one regular user more ;)

#### Posting Permissions

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