Solved

How do access data in a 2-dimensional array?

Posted on 2013-12-11
2
196 Views
Last Modified: 2013-12-11
I have a 2-dimensional array that I built. For some reason, I can't remember how to extract the data from it using a For Loop. Here is what I have, which doesn't make sense to me because it appears that I'm doing the same thing twice.

    Dim strData As String = ""

    For x As Integer = 0 to arrLoadTest.Length - 1
        For y As Integer = 0 to arrLoadTest.Length - 1
            strData = arrLoadTest(x, y)
        Next
    Next
0
Comment
Question by:BlakeMcKenna
2 Comments
 
LVL 62

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 39711862
That is correct. While the first loop x goes from o to the end of the first index the second loop y is going through the second index in like manner. So that it accesses the array as follows:

arrLoadTest(0,0),  arrLoadTest(0,1), ..., arrLoadTest(0,n)
arrLoadTest(1,0),  arrLoadTest(1,1), ..., arrLoadTest(1,n)
...
arrLoadTest(m,0),  arrLoadTest(m,1), ..., arrLoadTest(m,n)
0
 

Author Closing Comment

by:BlakeMcKenna
ID: 39711919
Ok, after I thought it through it made sense. The array was based off of a DataGridView (the number of rows and columns) so I just stored those values into variables and used those variables as the indexes.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now