As you code the examples in the chapter and this lesson, here's a handy technique you can use to figure out exactly what's happening in your loops. We'll use the endless loop example that is found in the book to illustrate it:
~~~~~~~~~~~~~~~~~~~~~~~~~
Dim Number As Double
Do
Number = InputBox( _
"Enter a number to square. Type -1 to quit.")
Number = Number * Number
TextBox.Text = Number
Loop While Number >= 0
~~~~~~~~~~~~~~~~~~~~~~~~~
When you run this program, it's not obvious why it won't accept the -1 input to quit. Rather than just scratching your head about it, why not get more information to work with using Debug.WriteLine!! Try entering these statements into the loop:
~~~~~~~~~~~~~~~~~~~~~~~~~
Dim Number As Double
Do
Number = InputBox( _
"Enter a number to square. Type -1 to quit.")
Debug.WriteLine("Number is: " & Number & " before square")
Number = Number * Number
TextBox.Text = Number
Debug.WriteLine("Number is: " & Number & " before test")
Loop While Number >= 0
~~~~~~~~~~~~~~~~~~~~~~~~~


