mamontenok
New Member
- Joined
- Mar 17, 2016
- Messages
- 2
Hi there,
Trying to come up with a code that will loop an infinite number of times until the user enters a specific range of values. I can do it using 'Do While' or 'Do Until' loops but the assignment specifically mentions 'For Loop'. Please help. Thanks!
Here is what I have now:
Option Explicit
Sub Problem3()
Dim i As Integer, n As Integer, num As Integer
n = 1000
For i = 0 To n
num = InputBox("Enter number")
If (num <= 20 And num >= 10) Then
MsgBox "Thank you for ending this loop"
Exit For
End If
Next i
End Sub
Trying to come up with a code that will loop an infinite number of times until the user enters a specific range of values. I can do it using 'Do While' or 'Do Until' loops but the assignment specifically mentions 'For Loop'. Please help. Thanks!
Here is what I have now:
Option Explicit
Sub Problem3()
Dim i As Integer, n As Integer, num As Integer
n = 1000
For i = 0 To n
num = InputBox("Enter number")
If (num <= 20 And num >= 10) Then
MsgBox "Thank you for ending this loop"
Exit For
End If
Next i
End Sub