Microsoft Office Tutorials and References
In Depth Information
TextLen = Len(text)
For i = TextLen To 1 Step -1
REVERSETEXT = Mid(text, i, 1) & REVERSETEXT
MsgBox REVERSETEXT
Next i
End Function
When this function is evaluated, a pop-up message box appears, once for each time through the loop. The mes-
sage box shows the current value of REVERSETEXT. In other words, this technique enables you to monitor the
results as the function is executed. Figure 24-6 shows an example.
Figure 24-6: Use a MsgBox statement to monitor the value of a variable as a Function procedure executes.
The information displayed in the series of message boxes shows that the text string is being built within the
loop, but the new text is being added to the beginning of the string, not the end. The corrected assignment state-
ment is
REVERSETEXT = REVERSETEXT & Mid(text, i, 1)
When the function is working properly, make sure that you remove all the MsgBox statements.
Search JabSto ::




Custom Search