I'm needing to generate 5 random times between 08:20:00 and 08:29:59.
These times need to be added into the top text boxes from left to right.
I'm currently doing it with this code:
private void Button1_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
Random random = new Random();
TimeSpan start = TimeSpan.FromHours(08.20);
TimeSpan end = TimeSpan.FromHours(08.30);
int maxMinutes = (int)((end - start).TotalMinutes);
for (int i = 0; i < 5; ++i)
{
int minutes = random.Next(maxMinutes);
TimeSpan t = start.Add(TimeSpan.FromMinutes(minutes));
listBox1.Items.Add(t);
}
}
And this is what it looks like.
Currently, it's not generating them between the time frame and it's also not including seconds which is critical. I also need a solution to add them into their slots.
1st generated needs to go into monday_In, 2nd needs to go into tuesday_In, 3rd needs to go to wednesday_In, 4th needs to go to thursday_In, 5th needs to go to friday_In
Any ideas on how to do this?