|
-
Jan 31st, 2007, 10:07 AM
#1
Thread Starter
Junior Member
Finding max value in Two dimensional array???
Hey everybody.....are we ready for the superbowl?
I am working on a project where I have multiple tow dimensional arrays. I am trying to find the max value in the first "column" of my array. I have searched the net but I have only found ways to find the max values in a one dimensional array......can anyone help?
-
Jan 31st, 2007, 10:14 AM
#2
Re: Finding max value in Two dimensional array???
Is this what your looking for?
VB Code:
Dim aryString(15, 30) As String
aryString.GetUpperBound(0) 'Would return a value of 15
aryString.GetUpperBound(1) 'Would return a value of 30
-
Jan 31st, 2007, 10:16 AM
#3
Fanatic Member
Re: Finding max value in Two dimensional array???
Correct me if i'm wrong, but doesn't .GetUpperBound(0) return the last element in the array???
If your problem has been solved then please mark the thread [RESOLVED].
If i have helped then please Rate my post 
-
Jan 31st, 2007, 11:30 AM
#4
Thread Starter
Junior Member
Re: Finding max value in Two dimensional array???
No... My array is as follows;
Dim Array1(,) As Double
ReDim Array1(30, 2)
The data in the array would look like this:
(0,0) = -36.5
(0,1) = 12
(0,2) = 6
(1,0) = -37.9
(1,1) = 9
(1,2) = 7
and so on.
I want to find the position of the max value in the first "column". For example the max of (0,0) -36.5 and (1,0)-37.9. In this case the position would be (0,0).
-
Jan 31st, 2007, 11:54 AM
#5
Re: Finding max value in Two dimensional array???
I think he means the highest value within an array. A multi-dimension array does not have "columns" as you may think. It is actually a matrix, so you will have to permatate each item like so:
VB Code:
Dim intArray(10, 20) As Integer
Dim MeRandom As New Random
For intIndex As Integer = 0 To intArray.GetUpperBound(0)
For intInnnerIndex As Integer = 0 To intArray.GetUpperBound(1)
intArray(intIndex, intInnnerIndex) = MeRandom.Next
Next
Next
Dim intFoundOutter As Integer
Dim intFoundInner As Integer
Dim intCurrentHighestValue As Integer = -1
'Check through the entire set to find the highest value
For intIndex As Integer = 0 To intArray.GetUpperBound(0)
For intInnnerIndex As Integer = 0 To intArray.GetUpperBound(1)
If intArray(intIndex, intInnnerIndex) > intCurrentHighestValue Then
intCurrentHighestValue = intArray(intIndex, intInnnerIndex)
intFoundOutter = intIndex
intFoundInner = intInnnerIndex
End If
Next
Next
MessageBox.Show("Found highest number of " & intCurrentHighestValue.ToString & " at (" & intFoundOutter.ToString & "," & intFoundInner.ToString & ")")
-
Jan 31st, 2007, 02:02 PM
#6
Thread Starter
Junior Member
Re: Finding max value in Two dimensional array???
Thanks a lot.... I am up and running now.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|