Microsoft Office Tutorials and References
In Depth Information
Sub Test()
x = REVERSETEXT(“Hello”)
MsgBox x
End Sub
This Sub procedure simply calls the REVERSETEXT function and assigns the result to a variable named x. The
MsgBox statement displays the result.
You can execute the Sub procedure directly from the VB Editor. Simply move the cursor anywhere within the
procedure and choose Run Run Sub/UserForm (or just press F5). When you execute the Test procedure, you
see the error message that is shown in Figure 24-8.
Click the Debug button, and the VB Editor highlights the statement causing the problem (see Figure 24-9). The
error message does not tell you how to correct the error, but it does narrow your choices. After you identify the
statement that's causing the error, you can examine it more closely, or you can use the Immediate window. See
the sidebar, “Using the Immediate window,” to help locate the exact problem.
In this case, the problem is the use of the And operator instead of the concatenation operator (&). The correct
statement is as follows:
REVERSETEXT = REVERSETEXT & Mid(text, i, 1)
Figure 24-8: A runtime error identified by VBA.
Search JabSto ::




Custom Search