I made a n-variable linear equation solver for a semester homework. It works fine (I already took some help from the site) only one feature is left which is loading the variables from the '.dat' file and copying them in the dynamic textboxes in the right order.
The jagged array is holding the variables for example, if the I have '2x+y=5', '3x-y=4' in my array, it should be changed to {2,1,5} and {3,-1,4}, the "ismeretlenek" represents the number of the variables.
How can I fill these textboxes from the '.dat' file?
ismeretlen = (int)numericUpDown1.Value;
TB = new TextBox[ismeretlen][];
for(int i = 0; i < ismeretlen; i++)
TB[i] = new TextBox[ismeretlen + 1];
int height = 20;
int width = 40;
int curX = 10;
int curY = 10;
for(int i = 0; i < ismeretlen; i++)
{
for(int j = 0; j < ismeretlen + 1; j++)
{
TextBox txtbox = new TextBox();
txtbox = new TextBox();
txtbox.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
txtbox.Left = curX;
txtbox.Top = curY;
txtbox.Width = width;
txtbox.Height = height;
txtbox.Font = new Font(txtbox.Font.FontFamily, 14);
txtbox.BackColor = Color.Azure;
txtbox.TextAlign = HorizontalAlignment.Center;
txtbox.Text = "0";
TB[i][j] = txtbox;
this.panel1.Controls.Add(TB[i][j]);
curX += width + 15;
}
curX = 10;
curY = curY + height + 20;
}
}
private void Save_Click(object sender, EventArgs e)
{
for (int a = 0; a < ismeretlen; a++)
segéd[a] = new double[ismeretlen + 1];
for (int a = 0; a < ismeretlen; a++)
{
for (int b = 0; b < ismeretlen + 1; b++)
{
segéd[a][b] = double.Parse(TB[a][b].Text);
}
}
string file = ismeretlen+"ismeretlen.dat";
FileStream fs = new FileStream(file, FileMode.Create);
BinaryWriter bw = new BinaryWriter(fs);
for (int r = 0; r < ismeretlen; r++)
for (int t = 0; t < ismeretlen + 1; t++)
bw.Write(segéd[r][t]);
bw.Close();
fs.Close();
}
private void Load_Click(object sender, EventArgs e)
{
}
}