Try this; i just knocked this up in C# and works fine (learn something new everyday!)
create a form with 2 buttons on it; One does the create, and one does the output to debug window;
This is the code to create 100 textboxes named
TextBox0
to
TextBox99
and set their text to a value from 0 to 99 and also the matrix class variable. It will then search the forms controls collectin for each textbox and load its value to the matrix.
private int[,] matrix = new int[10, 10];
public void create100textboxes()
{
for (int i = 0; i < 100; i++)
{
TextBox newTextbox = new TextBox();
newTextbox.Name = "TextBox" + i.ToString();
newTextbox.Text = i.ToString ();
this.Controls.Add(newTextbox);
newTextbox.BringToFront();
}
int textBoxCount = 0;
for (int r = 0; r < 10; r++)
{
for (int c = 0; c < 10; c++)
{
TextBox currentTextBox = (TextBox) Controls[Controls.IndexOfKey("TextBox" + textBoxCount.ToString())];
matrix[c,r] = int.Parse(currentTextBox.Text);
textBoxCount++;
}
}
}
The code below will iterate through the matrix and output to the debug window each row/col address;
private void buttonPrint_Click(object sender, EventArgs e)
{
for (int r = 0; r < 10; r++)
{
for (int c = 0; c < 10; c++)
{
System.Diagnostics.Debug.Print("Matrix[" + r + "," + c + "]=" + matrix[r, c]);
}
}
}