pschuler123
New member
- Joined
- Jan 5, 2005
- Messages
- 1
- Programming Experience
- Beginner
I have a form with a number of label controls on it. Based on a click event I would like the label controls backcolor property to change. I want a five second delay between each change. I have tried adding a timer control and enabling it in the click event with the interval property set to 5000. This does nothing. Tried using the following code:
For n = 1 To daysComplete()
LabelArray.BackColor = System.Drawing.Color.Red
LabelArray.Text = n
System.Threading.Thread.CurrentThread.Sleep(5000)
System.Threading.Thread.CurrentThread.Resume()
Next n
This caused the application to go into a 'Not Responding' status and I had to end task. I'm assuming this is the wrong place to insert this code. Anyone have any ideas. Thanks.
This ended up working for me. Thanks
For n = 1 To daysComplete()
LabelArray.BackColor = System.Drawing.Color.Red
LabelArray.Text = n
System.Threading.Thread.CurrentThread.Sleep(3000)
System.Windows.Forms.Application.DoEvents()
Next n
For n = 1 To daysComplete()
LabelArray.BackColor = System.Drawing.Color.Red
LabelArray.Text = n
System.Threading.Thread.CurrentThread.Sleep(5000)
System.Threading.Thread.CurrentThread.Resume()
Next n
This caused the application to go into a 'Not Responding' status and I had to end task. I'm assuming this is the wrong place to insert this code. Anyone have any ideas. Thanks.
This ended up working for me. Thanks
For n = 1 To daysComplete()
LabelArray.BackColor = System.Drawing.Color.Red
LabelArray.Text = n
System.Threading.Thread.CurrentThread.Sleep(3000)
System.Windows.Forms.Application.DoEvents()
Next n
Last edited: