Im trying to make a simple windows form that records the date based on a click on a month calendar, the distance driven and time taken based on text box inputs.
Im ok with arrays in console mode but no idea when it comes to forms/button click events.
this code works on a single button click and will print to a text box using the print method below. What I don't know how to do is make it so that every time i click the save button it increases the index and stores the next record without wiping the 1st record
I know it will need the index i to be declared somewhere and a counter increase used but have no idea where to start
private void btnDate_Click(object sender, EventArgs e)
{
if (IsDataValid()) // error checking
{
date[i] = txtDate.Text;
distance[i] = decimal.Parse(txtDistance.Text.ToString());
time[i] = int.Parse(txtDistance.Text.ToString());
}
}
print method
public void PrintDetails()
{
for (int i = 0; i < MAXSIZE; i++)
{
textBox1.Text = date[i] + " Distance : " + distance[i] +
" Time: " + time[i] + " \n";
}
}
private void btnPrint_Click(object sender, EventArgs e)
{
PrintDetails();
}
any pointers in the right direction would be awesome