I have 30 or so textboxes that I have labeled in order {ex: R1C1B1, R1C2B1, R2C1B1, ...}
Here is my code:
private void Solve(int row, int column, int box)
{
string numbers = "123456789";
TextBox newTextBox = (TextBox)Controls.Find(string.Format("tbox{0}", "R" + row.ToString() + "C" + column.ToString() + "B" + box.ToString()), false).FirstOrDefault();
MessageBox.Show(newTextBox.Text);
if (newTextBox.Text != "")
{
return;
}
numbers = numbers.Replace(checkRow(row, column), "");
numbers = numbers.Replace(checkColumn(row, column), "");
numbers = numbers.Replace(checkBoxPos(row, column), "");
if (numbers.Length == 1)
{
newTextBox.Text = numbers;
}
}
Whenever I try to use MessageBox.Show to view what is in the textbox I get the error in the title. Here is all of the error:
An unhandled exception of type 'System.NullReferenceException' occurred in SudokuSolver.exe
Additional information: Object reference not set to an instance of an object.