WD: WordBasic: Using Line Numbers with Goto StatementsLast reviewed: February 2, 1998Article ID: Q97660 |
The information in this article applies to:
SUMMARYTo use the WordBasic Goto statement in your Word macro to branch to a specific line number in the macro, your macro must contain a line number at the beginning of the line. For example, to use the Goto 20 statement, you should number the lines in your macro as shown in the following sample macro:
Sub Main 5 A$=inputbox$("Who is it?") 10 if a$="" then GOTO 20 15 Print A$ 16 Goto 25 20 Print "You didn't enter anything" 25 End SUBFor more information about the Goto statement, see page 230 of "Using WordBasic."
MORE INFORMATIONIn the Word for Windows WordBasic macro language, it is not customary to number the lines of your macro, but it is acceptable to do so. Do not type a colon (:) after the number. For example, the following line does not contain a valid line number, while the macro in the previous section does contain valid line numbers:
15: Print A$Line numbers do not need to be continuous, and you can number the lines in ascending as well as descending order, as shown in the sample macro below. It is a programming custom to number lines in ascending order.
Sample Macro, Numbered Noncontinuously in Descending Order
Sub MAIN 100 Goto 30 35 MsgBox "line 35" Goto 10 30 MsgBox "line 30" 450 Goto 35 10 MsgBox "line 10" End SUB REFERENCES"Using WordBasic," by WexTech Systems and Microsoft, page 230
|
Additional query words: macro
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |