# Finding the highest value in an array row & returning column num.

Page 1 of 1

## 4 Replies - 575 Views - Last Post: 27 October 2016 - 10:50 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=398394&amp;s=f14b4ff292e0f33f27c5513facb65759&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 CarolinaN

Reputation: 0
• Posts: 4
• Joined: 01-October 16

# Finding the highest value in an array row & returning column num.

Posted 27 October 2016 - 01:10 PM

The title basically explains it, but here we go:

I have an array with 26 columns and 2 rows. The first row contains the values 65 - 90 in ascending order. The second row will contain a range of numbers. I need to find the highest value in the second row and return the column number. Any help on how to do this? I've looked at some example code, but I can only find 1 dimensional arrays for max values.

In case it would help, here is my code:

(Ciphertext isn't currently there, but it would just be a piece of text)
```Module Module1

Sub Main()
Dim num As Integer
'Ciphertext goes between the two speech marks next line
Dim ciphertext As String = UCase("")
Dim array(25, 2) As Integer
For a = 1 To 26
array(a - 1, 0) = a + 64
array(a - 1, 1) = 0
Next

For b = 0 To ciphertext.Length
num = Asc(ciphertext.Substring(b, 1))
Select Case num
Case 65 To 90
array(num, 1) = array(num, 1) + 1
End Select
Next

End Sub

End Module

```

Is This A Good Question/Topic? 0

## Replies To: Finding the highest value in an array row & returning column num.

### #2 horace

• D.I.C Lover

Reputation: 768
• Posts: 3,832
• Joined: 25-October 06

## Re: Finding the highest value in an array row & returning column num.

Posted 27 October 2016 - 01:24 PM

not sure why you require the first row? it just has the values 65, 66, 67 .... etc
once you find the maximum in the second row the value of the first row would be column+65?

### #3 CarolinaN

Reputation: 0
• Posts: 4
• Joined: 01-October 16

## Re: Finding the highest value in an array row & returning column num.

Posted 27 October 2016 - 01:46 PM

K, sorry if I'm just being dumb at this point. I modified the code so it's just one row, how do I then find which column it is in? I'm sure I'm just missing a function, but so far my efforts are not really doing much.

### #4 horace

• D.I.C Lover

Reputation: 768
• Posts: 3,832
• Joined: 25-October 06

## Re: Finding the highest value in an array row & returning column num.

Posted 27 October 2016 - 10:16 PM

if you do a web search for "vb.net array maximum" you will find many links, e.g.
http://www.freevbcod...ode.asp?ID=8459
https://www.dotnetpe...h-max-min-vbnet

### #5 andrewsw

• RequestedRangeNotSatisfiable

Reputation: 6561
• Posts: 26,600
• Joined: 12-December 12

## Re: Finding the highest value in an array row & returning column num.

Posted 27 October 2016 - 10:50 PM

If you are using a variable x to loop through and find the largest number then, when you encounter this largest number, make a note of (store) the x-value where the number occurred. If you find a bigger number, store its x-value instead. Once you've completed the loop x will tell you where the biggest number lives. x marks the spot.