Microsoft KB Archive/36737

From BetaArchive Wiki
Knowledge Base

Longer Variable Names Take No Extra Space in .EXE Program

Article ID: 36737

Article Last Modified on 11/21/2006


  • Microsoft QuickBasic 1.0
  • Microsoft QuickBasic 1.01
  • Microsoft QuickBasic 1.02
  • Microsoft QuickBasic 2.0
  • Microsoft QuickBasic 2.01
  • Microsoft QuickBasic 3.0
  • Microsoft QuickBasic 4.0
  • Microsoft QuickBASIC 4.0b
  • Microsoft QuickBasic 4.5 for MS-DOS
  • Microsoft BASIC Professional Development System 7.0
  • Microsoft BASIC Compiler 6.0
  • Microsoft BASIC Compiler 6.0b

This article was previously published under Q36737


In programs compiled by BC.EXE, you will not change the generated code size by using shorter variable names instead of longer ones. The generated .OBJ and .EXE file sizes are independent of the length of variable names.

Although BC.EXE uses variable names at compile time to allocate memory and translate Basic statements to machine code, these symbolic names are not embedded in the code produced by the compiler.

This information applies to Microsoft QuickBasic Versions 1.00, 1.01, 1.02, 2.00, 2.01, 3.00, 4.00, 4.00b, and 4.50; to Microsoft Basic Compiler Versions 6.00 and 6.00b for MS-DOS and MS OS/2; and to Microsoft Basic PDS Version 7.00 for MS-DOS and MS OS/2.


Source code can be much more readable if you use fully-descriptive names in naming variables. QuickBasic allows variable names up to 40 characters in length. Consider the following choices of variable names:

   mfp     versus      MeanFreePath
   n$      versus      LastName$
   vo      versus      Volts
   vl      versus      Volume
   vc      versus      Velocity

The names in the right column generate no more code than those on the left side.

However, within the QB.EXE program development environment, all text in the source file occupies memory, including long variable names.

Additional query words: QuickBas BasicCom

Keywords: KB36737