Basic Products Can Create and Use Non-Standard File Names

Last reviewed: June 21, 1995
Article ID: Q94783
The information in this article applies to:

- Standard and Professional Editions of Microsoft Visual Basic for

  Windows, versions 2.0 and 3.0
- Microsoft Visual Basic programming system for Windows, version 1.0 - The Standard and Professional Editions of Microsoft Visual Basic
  for MS-DOS, version 1.0
- Microsoft Basic Professional Development System (PDS) for MS-DOS,
  version 7.1
- Microsoft QuickBASIC for MS-DOS, version 4.5

SUMMARY

Microsoft Visual Basic and other Basic products can create and use non-standard MS-DOS file names. For example, a file name with an embedded space is a non-standard file name. However, Microsoft doesn't recommend that you use non-standard file names because they can cause problems with other software.

MORE INFORMATION

According to the MS-DOS documentation, file names must:

  • Have no more than eight characters.
  • Contain only the letters A through Z, the numbers 0 through 9, and the following special characters: underscore (_), caret (^), dollar sign ($), tilde (~), exclamation point (!), number sign (#), percent sign (%), ampersand (&), hyphen (-), braces ({}), parentheses (), at sign (@), apostrophe ('), and the accent grave (`). No other special characters are acceptable.
  • Not contain spaces, commas, backslashes, or periods except for the period that separates the name from the extension.
  • Not be the following reserved filenames: CLOCK$, CON, AUX, COMn (where n=1-4), LPTn (where n=1-3), NUL, and PRN.

The Basic OPEN command allows you to open a file name that breaks some of these rules. For example, you can open a file that has a space embedded in its name.

The following example creates a file giving it a name that contains a space. Then it writes data to the file, reopens it, and prints the data on the screen:

  OPEN "A B" FOR OUTPUT AS #1 'There is a space between A and B
  PRINT #1, "HELLO THERE"
  CLOSE #1

  OPEN "A B" FOR INPUT AS #1
  INPUT #1, A$
  PRINT A$
  CLOSE #1


Additional reference words: 1.00 2.00 3.00 4.50 7.10
KBCategory: kbprg
KBSubcategory: PrgOther


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: June 21, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.