Microsoft KB Archive/47124
Article ID: 47124
Article Last Modified on 11/21/2006
This article was previously published under Q47124
In QuickBasic versions 3.00 and earlier, passing an array in a SUB statement requires the number of array dimensions to be specified in parentheses, such as x(2) for an array dimensioned as DIM x(10,10). Empty parentheses () after the array name in a SUB statement cause a compile-time error in QuickBasic 3.00 and earlier.
However, in QuickBasic versions 4.00 and later, empty parentheses after the array name in a SUB statement are actually the preferred syntax. They are also the preferred syntax in Microsoft Basic Compiler versions 6.00 and 6.00b for MS-DOS and MS OS/2 and in Microsoft Basic Professional Development System (PDS) version 7.00 for MS-DOS and MS OS /2.
In fact, the QB.EXE editor in QuickBasic versions 4.00, 4.00b, and 4.50 and the QBX.EXE editor in Basic PDS version 7.00 automatically strip out the constant (if any) in the parentheses net to the array name in a SUB statement.
When using a text editor (word processor, EDLIN, etc.) and writing the program using the syntax for QuickBasic versions 3.00 or earlier, you will get an "L1101 Invalid Object Module" error when trying to link the .OBJ that was created using QuickBasic versions 4.00 or later.
The subroutine example for the LBOUND and UBOUND functions in the manuals doesn't require the subscript (2) in the array in the SUB statement. This applies to Page 60 of the "Microsoft QuickBasic 4.0: Programming in Basic: Selected Topics" manual for QuickBasic versions 4.00 and 4.00b and for Microsoft Basic Compiler versions 6.00 and 6.00b for MS-DOS and MS OS/2, and to Page 53 of the "Microsoft QuickBasic 4.5: Programming in Basic" manual for QuickBasic version 4.50. This misleading documentation was changed in Microsoft Basic PDS version 7.00.
The first line of the subroutine example shows the following, which is allowed but may be a little misleading, since QB.EXE and QBX.EXE strip out the "2":
SUB PrintOut(A(2)) STATIC
No number of dimensions (2) is required for the A array. This line converts to the following preferred syntax when entered in the QB.EXE and QBX.EXE editor:
SUB PrintOut(A()) STATIC
Additional query words: QuickBas BasicCom