txtOutput.Text += "Filling the array with user input..." + "\r\n"; txtOutput.Text += "The product allocation is as follows:" + "\r\n\r\n"; int[,] toys = new int[5, 4]; for (int week = 0; week <= 3; week++) { for (int day = 0; day <= 4; day++) { int tempVal = 0; if (int.TryParse(Microsoft.VisualBasic.Interaction.InputBox("Please enter value for Day " + (day + 1) + " in week " + (week + 1) + "."), out tempVal)) { toys[day, week] = tempVal; } else { MessageBox.Show("Invalid entry"); day--; continue; } //the first line must be separate because the headings are not part of the array txtOutput.Text += "\t\t" + "Mon" + "\t" + "Tue" + "\t" + "Wed" + "\t" + "Thu" + "\t" + "Fri" + "\t" + "\r\n"; for (week = 0; week <= 3; week++)//foreach week { //construct the line of text which represents the week's data txtOutput.Text += "\tWeek " + (week + 1) + "\t"; for (day = 0; day <= 4; day++) { txtOutput.Text += toys[day, week]; if (day != 4) { //so long as it is not the last day, then it tabs over txtOutput.Text += "\t"; } } //moving over to the next line txtOutput.Text += "\r\n\r\n"; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)