Microsoft KB Archive/37348

= New COMMAND$ Will Not Pass with RUN from within VB Program =

Article ID: 37348

Article Last Modified on 8/16/2005

-

APPLIES TO


 * Microsoft Visual Basic for MS-DOS
 * Microsoft QuickBasic 4.0
 * Microsoft QuickBASIC 4.0b
 * Microsoft QuickBasic 4.5 for MS-DOS
 * Microsoft BASIC Compiler 6.0
 * Microsoft BASIC Compiler 6.0b
 * Microsoft BASIC Professional Development System 7.0
 * Microsoft BASIC Professional Development System 7.1

-



This article was previously published under Q37348



SUMMARY
A Visual Basic for MS-DOS, version 1.0 program will return the COMMAND$ as expected, but the RUN statement with an appended command string will not pass the COMMAND$ to the new program. Instead, the original COMMAND$ from the first program is passed to the second (RUN) program. The two programs listed below demonstrate this behavior.



MORE INFORMATION
If you type &quot;PROG1 /Z&quot; on the MS-DOS command line, &quot;/Z&quot; is returned with the COMMAND$ function in both programs listed below, regardless of what is entered for X$ in Prog1. Because the RUN statement is used with a quoted string, the &quot; + X$&quot; is concatenated to the program name string. This means that if X$ equals &quot;/B&quot;, then the RUN statement is actually RUN &quot;PROG2.EXE/B&quot;, which is not a valid filename. ' To try the following examples in VBDOS.EXE: ' 1. From the File menu, choose New Project. ' 2. Copy the code example to the Code window. ' 3. Press F5 to run the program.

REM  *** Prog1 *** PRINT &quot;Here is the COMMAND$: &quot;; COMMAND$ INPUT &quot;Enter the new COMMAND$&quot;; X$ RUN &quot;PROG2.EXE&quot; + X$                      ' Either .BAS or .EXE. END

REM  *** Prog2 *** PRINT &quot;Here is the COMMAND$: &quot;; COMMAND$ END

Additional query words: VBmsdos QuickBas BasicCom 1.00 4.00 4.00b 4.50 6.00 6.00b 7.00

Keywords: KB37348

-

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

© Microsoft Corporation. All rights reserved.