VB6 beginners tutorial - Learn VB6

Advanced VB6 tutorial - Learn Advanced VB6

Systems Analysis - System analysis and Design tutorial for Software Engineering

You are here: Visual Basic > Advanced VB6 tutorial > Chapter 20

Chapter 20 - Compiling a VB Application

( Contents )

Visual Basic includes a native-language compiler. This compiler can translate the Visual Basic source code that programmers can read and understand into executable programs consisting of native machine code that computers can read and understand.

Versions of Visual Basic before version 5 also produce executable files, but the code in those executables does not consist of native machine code. Until versions 5 and 6, executable program files produced by Visual Basic consisted of something generally known as pseudocode, or P-Code, rather than native machine code. Native code provides a performance advantage over P-Code that VB programmers have wanted for a long time.

As if it weren’t enough to include a native code compiler, Microsoft also gave VB an optimizing compiler. In addition to the performance advantage inherent in native code compilation, the optimization switches enable discerning VB programmers to tweak their applications for even greater performance.

However, Microsoft still allows the programmer to choose P-Code compilation for any project.

Although the primary purpose of source code is to provide clear instructions for the CPU, it is occasionally useful to be able to talk to the compiler too. When necessary, this permits you to give the compiler special instructions about how it should produce the code that finally gets sent to the CPU.

Visual Basic enables the programmer to talk directly to the compiler itself by embedding instructions directed to the compiler in VB source code.

This chapter discusses the consequences of choosing different compiler options in a VB project and also discusses how you can manipulate the compiler directly by using compiler directives.

Specifically, this chapter covers the following topics:

  • P-Code versus native code
  • When and how to optimize
  • Using compile on demand
  • Conditional compilation defined
  • Preprocessor directives
  • Preprocessor constants
  • Applications and styles



  1. Native Code

  2. Interpreted Code

  3. Understanding Early Pseudocode

  4. P-Code

  5. Understanding When and How to Optimize

    Compiling to P-Code

    Compiling to Native Code

    Basic Optimizations
    Optimizing for Fast Code
    Optimizing for Small Code, No Optimization
    Favoring Pentium Pro, Creating Symbolic Debug Info
    Results of Basic Optimization

    Advanced Optimizations
    Assuming No Aliasing
    Removing Array Bounds Checks
    Removing Integer Overflow Checks, Removing Floating-Point Error Checks
    Allowing Unrounded Floating-Point Operations, Removing Safe Pentium FDIV Checks

  6. Using Compile On Demand

  7. Understanding Conditional Compilation

    Preprocessor Directives

    Types of Expressions

    Compiler Constants
    Predefined Compiler Constants
    Declaring Compiler Constants
          Declaring in Code
          Declaring in the Project Properties Dialog Box
          Declaring in the Command Line
    Scope and Persistence

  8. Applications and Styles


Get Started >>

Home | About Us | Privacy Policy | Contact Us

Copyright © | All Rights Reserved