I am new to Visual Basic and am using the 2005 Express Edition.
Can anyone please tell me why the following code does not produce 10 Beeps with a short delay between each one.
For
For Tim As Integer = 1 To 50
Beep()
Next Tim
Next Int
I am new to Visual Basic and am using the 2005 Express Edition.
Can anyone please tell me why the following code does not produce 10 Beeps with a short delay between each one.
For
Delay using nesting in For Next Loop
ericsstoll
maheshbabui
For Int As Integer = 1 To 10
Beep()
For Tim As Integer = 1 To 50
Next
Next Int
However, using a for-loop to delay code execution is not appropriate on modern computers. If the compiler is not smart enough to remove the empty loop in the first place, computers today have very different speeds, resulting in a different delay length. Plus, a loop of 1..50 is executed very fast these days... The appropriate method to delay is System.Threading.Thread.Sleep(...).
J.M. Dussault
AvinashA
http://msdn.microsoft.com/library/default.asp url=/library/en-us/cpref/html/frlrfSystemThreadingThreadClassSleepTopic.asp
M-Studios
Have searched for info on 'Sleep' but have had no joy.
Can you give me a clue
zkent
Now have a countdown Timer.
Sergio G
It's back to the drawing board. I'm glad it's a hobby and I just do it for fun.
I've moved up from Windows 98 to XP with a new computer so I have plenty to accupy my mind at the moment. Thanks again.
Steep