Examples: While statement

' While a user-specified interval (in seconds) is elapsing,
' beep and count the beeps. Then tell the user the number
' of beeps.
Dim howLong As Single, howManyBeeps As Integer
Function HowManyTimes (howLong As Single) As Integer
   Dim start As Single, finish As Single, counter As Integer
   start! = Timer
   finish! = start! + howLong!
   While Timer < finish!
      counter% = counter% + 1
   HowManyTimes = counter%
End Function
howLong! = CSng(InputBox _
   ("For your own sake, enter a small number."))
howManyBeeps% = howManyTimes(HowLong!)
MessageBox "Number of beeps:" & Str(howManyBeeps%)