Microsoft KB Archive/59758

= Single-Line IF...THEN Label, &quot;Syntax Error&quot;; Requires GOTO =

Article ID: 59758

Article Last Modified on 11/21/2006

-

APPLIES TO


 * Microsoft QuickBasic 2.0, when used with:
 * Microsoft MS-DOS 6.22 Standard Edition
 * Microsoft QuickBasic 2.01, when used with:
 * Microsoft MS-DOS 6.22 Standard Edition
 * Microsoft QuickBasic 3.0, when used with:
 * Microsoft MS-DOS 6.22 Standard Edition
 * Microsoft QuickBasic 4.0, when used with:
 * Microsoft MS-DOS 6.22 Standard Edition
 * Microsoft QuickBASIC 4.0b, when used with:
 * Microsoft MS-DOS 6.22 Standard Edition
 * Microsoft QuickBasic 4.5 for MS-DOS, when used with:
 * Microsoft MS-DOS 6.22 Standard Edition
 * Microsoft BASIC Compiler 6.0
 * Microsoft BASIC Compiler 6.0b
 * Microsoft BASIC Professional Development System 7.0

-



This article was previously published under Q59758



SUMMARY
A single-line IF statement of the form IF THEN causes a &quot;Syntax Error.&quot; In a single-line IF statement, you must use the GOTO statement to branch to a line label. This is different from the branching rule for line numbers, where the GOTO is optional.

This information applies to Microsoft QuickBASIC Versions 2.00, 2.01, 3.00, 4.00, 4.00b, and 4.50 for MS-DOS, to Microsoft BASIC Compiler Versions 6.00 and 6.00b for MS-DOS and OS/2, and to Microsoft BASIC Professional Development System (PDS) Version 7.00 for MS-DOS and MS OS/2.



MORE INFORMATION
The following is the single-line IF statement syntax. (It is taken from the QuickBASIC 4.50 QB Advisor online Help system): IF booleanexpression THEN thenpart [ELSE elsepart] The thenpart and the elsepart both have the following syntax:

{statements | [GOTO]linenumber | GOTO linelabel }

The following list describes the parts of the thenpart and elsepart syntax:      Part         Description ---

statements  One or more BASIC statements, separated by colons

linenumber  A valid BASIC program line number

linelabel   A valid BASIC line label

A Related Issue in QuickBASIC for the Apple Macintosh
Note that QuickBASIC for the Apple Macintosh does not require the GOTO for a label in an IF statement. This prevents making an implicit CALL, as in the IF...THEN subname statement. For more information, query on the following words:

Macintosh and QuickBASIC and GOTO and implicit and subprogram and explicit

Code Example
The following code example causes a syntax error on the IF statement: IF 1 = 1 THEN Label     'Should be: IF 1 = 1 THEN GOTO Label Label: PRINT &quot;Made it!&quot;

Additional query words: QuickBas BasicCom MQuickB

Keywords: KB59758

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.