Solitaire
Sorry, that doesn't help.
I need something as simple as the code I posted above. It needs to be placed in the button click event, and it will be repeated dozens of times for split seconds each time as the textbox keeps refreshing. Other pauses with varying times (fractions of a second) will also be used in the same event to separate each of 8 textboxes, (which I set up as an array of textboxes in a separate sub). As you can see, every statement using System.Threading.Thread.Sleep should be replaced with a pause using a Timer instruction, but as simply and clearly as possible!
Here is part of the actual code I'm using now. It works perfectly except that the user cannot interrupt the process to select another event.
Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click
Dim winner, L, idig, Q, R As Integer
Dim swin, dig As String
' ' ' Note: Some code omited here -- Some variables were declared at class-level
winner = shuffle(win)
swin = winner.ToString
L = N - swin.Length
swin = StrDup(L,
"0") & swin
win = win + 1
If flash = False Then 'show winning number instantly
' ' ' Code omitted since it doesn't use a pause
Else
If win = 1 Then
lblWait.Text =
"Always wait for flash to stop before clicking Next or another button."
lblWait.Refresh()
System.Threading.Thread.Sleep(100)
End If
For x As Integer = 1 To 8 'clear previous winning number
TextArray(x).Clear()
TextArray(x).Refresh()
Next x
System.Threading.Thread.Sleep(200)
'pause before next number
lblIndex.ForeColor = Color.FromArgb(130, 130, 130)
lblIndex.Text = win.ToString
'winner count in gray
lblIndex.Refresh()
Q = N
If P > 0 Then 'don't flip inactive digits
For x As Integer = N To N - P Step -1
dig = swin.Substring((N - x), 1)
TextArray(x).ForeColor = Color.FromArgb(120, 120, 120)
TextArray(x).Text = dig
TextArray(x).Refresh()
System.Threading.Thread.Sleep(200)
Q = N - P
'active digits
Next x
End If
For x As Integer = Q To 1 Step -1 'flip winning number digits
dig = swin.Substring(N - x, 1)
idig = Convert.ToInt32(dig)
For y As Integer = 0 To 9 'first flip from 0 to 9
TextArray(x).ForeColor = Color.Black
TextArray(x).Text = y.ToString
TextArray(x).Refresh()
System.Threading.Thread.Sleep(90)
Next
For y As Integer = 0 To idig 'then flip from 0 to value
TextArray(x).Text = y.ToString
TextArray(x).Refresh()
System.Threading.Thread.Sleep(90)
Next y
System.Threading.Thread.Sleep(90)
Next x
lblIndex.ForeColor = Color.Black
'winner count in black after flip finishes
lblIndex.Refresh()
For y As Integer = 1 To 7 'flash winning number in gold
If y Mod 2 = 0 Then R = N Else R = Q
For x As Integer = 1 To R 'alternate active with all digits
TextArray(x).BackColor = Color.Gold
Next x
For x As Integer = 1 To N
TextArray(x).Refresh()
Next x
System.Threading.Thread.Sleep(200)
For x As Integer = 1 To N 'original color
TextArray(x).BackColor = Color.FromArgb(255, 255, 192)
Next x
For x As Integer = 1 To N
TextArray(x).Refresh()
Next x
System.Threading.Thread.Sleep(90)
Next y
lblWait.Text =
""
End If
End Sub