By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,479 Members | 988 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,479 IT Pros & Developers. It's quick & easy.

Procedure Question

P: n/a
Hi,

I have a procedure that runs a For ... Next loop. See below.

Private Sub DoThis()
Dim i As Integer
For i = 1 to 10
'code omitted because I don't want you to see it :-)
Next i
End Sub

What I would like to do is create a one second time frame between each time
the For...Next loop runs. Any suggestions on how to accomplish this?

Thanks,
Roshawn
Nov 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On Mon, 26 Jul 2004 23:46:17 -0500, Roshawn wrote:
Hi,

I have a procedure that runs a For ... Next loop. See below.

Private Sub DoThis()
Dim i As Integer
For i = 1 to 10
'code omitted because I don't want you to see it :-)
Next i
End Sub

What I would like to do is create a one second time frame between each time
the For...Next loop runs. Any suggestions on how to accomplish this?

Thanks,
Roshawn


Put the code in a timer event, with the interval set to 1000

Private Sub Timer_Tick(ByVal sender As Object, ByVal e As EventArgs)
Static i As Integer = 0

i += 1
If i < 10 Then
' Do Stuff
Else
' Where all done..
Timer.Enabled = False
i = 0
End If
End Sub

or alternatively, you can put it on another thread and then call
Thread.Sleep(1000) between iterations...

--
Tom Shelton [MVP]
Nov 20 '05 #2

P: n/a
Private Sub DoThis()
Dim i As Integer
For i = 1 to 10
'code omitted because I don't want you to see it :-)
System.Threading.Thread.Sleep(1000) 'sleep time in milliseconds;
so this sleeps for 1 sec
Next i
End Sub

that should work..

Imran.

"Roshawn" <ud****@bellsouth.net> wrote in message
news:eo**************@TK2MSFTNGP12.phx.gbl...
Hi,

I have a procedure that runs a For ... Next loop. See below.

Private Sub DoThis()
Dim i As Integer
For i = 1 to 10
'code omitted because I don't want you to see it :-)
Next i
End Sub

What I would like to do is create a one second time frame between each time the For...Next loop runs. Any suggestions on how to accomplish this?

Thanks,
Roshawn

Nov 20 '05 #3

P: n/a
Thank you both for your responses. I'll let you know how things turned out.

Roshawn
Nov 20 '05 #4

P: n/a
Everything turned out great. Thanks for your help!!!

Nov 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.