PDA

View Full Version : Solved: Bottom controlled Do While loop



austenr
03-11-2010, 03:01 PM
Struggling with the concept. Can anyone provide an example? Example. Start the loop and then have an input box asking if you want to continue the loop?

mdmackillop
03-11-2010, 04:41 PM
Doesn't sound complicated but I think we need a simple example.

mikerickson
03-12-2010, 03:22 PM
Do
Rem some stuff
Loop Until MsgBox("Another Loop?", vbYesNo) = vbNo

GTO
03-12-2010, 03:27 PM
Hi all,

I would imagine you meant a msgbox, but here's a simple example of either way.


Sub LoopCrazy()
Dim i As Long, bolOkayIveHadEnough As Boolean

Do
i = i + 1

If Not MsgBox("We're in Loop #" & i & vbCrLf & _
"Do you want to continue?", vbYesNo, vbNullString) = vbYes Then

bolOkayIveHadEnough = True

End If
Loop While Not bolOkayIveHadEnough

End Sub

Sub LoopyToo()
Dim i As Long

Do
i = i + 1
Loop While InputBox("""Yes"" to continue" & vbCrLf & "Loop #" & i, "") = "Yes"

End Sub

Mark

austenr
03-12-2010, 03:30 PM
Thanks guys I got it.