Learn the most popular programming language of the most popular Operating System: Windows


Compiled Application from Standard EXE Project

This final objective asks you create an executable file from a completed Visual Basic application.  Two options are available: Under the Compile tab of the Project Properties dialog box, you can select Compile to P-Code or Compile to Native Code (see Figure 2.10).  Compiling to native code is the default.

Figure 2.10The Compile tab of the Project Properties dialog box enables you to control the way in which you compile your completed application.

Interpreted P-Code

By selecting P-Code, the modules of your Visual Basic application are compiled into what is called pseudocode or false code.  An interpreter program that then produces machine language instructions reads the coded instructions.  All versions of Visual Basic prior to Visual Basic 5.0 were interpreted from P-Code.

Interpreted programs offer some advantage.  Applications can be designed rapidly because new code can be tested immediately, without time-consuming compilation.  They also offer some security advantages in networked applications.  You can rely on the interpreter to serve as a buffer between an application and computer hardware.  This is the security model built into the Java programming language, for example.  To their disadvantage, interpreted programs tend to run slower than compiled programs.

Compiled Native Code

With Visual Basic 5.0, you can create native code compiled applications:  The compiler takes the modules of your project and creates a machine language compiled application.  Although the native code executable does not require interpretation, it still depends on other files to run.  These files consist, mainly, of the object linking and embedding (OLE) libraries that make up the ActiveX architecture upon which Visual Basic is based.

One way to think about the difference between interpreted and compiled programs is to compare it to translating a letter from English to German (or another language).  A compiled program translates the entire letter once, producing machine-language instructions.  An interpreted program translates each letter every time the letter is read, producing P-Code, which is then translated into machine language.

The Make Tab of the Project Properties Dialog Box

When you decide to create an executable, the Make tab of the Project Properties dialog box comes into play.  The Make tab presents general attribute options for your executable (see Figure 2.11), including the title of the application, the icon used to represent the application when it is minimized, and different version options. The Make tab also enables you to set command-line arguments for your application should you decide to use them.

Figure 2.11The Make tab enables you to set version numbers, version information, application attributes, command-line arguments, and conditional compilation arguments.

Exercise 2.9  Creating an Executable Application

This exercise asks you to create a make file from the Happy Birthday application created in Exercise 2.8.

  1. Open Exercise 2.8 if it is not on the screen.
  2. Choose File, Make Project2-8, if this reflects the name you gave your project.
  3. When the Make Project dialog box opens, select a file name, such as BDAY1.EXE, and click OK.  That's it. You have created a native code executable file. Remember that native code is the default.
  4. Choose File, Make Project2-8 again, and when the dialog box opens, click Options.
  5. Click the Compile tab.
  6. Click Compile to P-Code, and click OK to return to the Make Project box.
  7. Select a different file name, such as DAY2.EXE.
  8. Close Visual Basic, and start Windows Explorer.  Locate both DBAY1.EXE and BDAY2.EXE.  Click BDAY1.EXE to run the program.  Close BDAY1.
  9. Click BDAY2.EXE to run the program.  Close BDAY2.


Popular Posts

Search This Blog

Powered by Blogger.

Featured Post

Coded Statements and Methods

In the preceding procedure , you wrote several coded instructions, which introduced two different programming statements and a method: the D...

Recent Posts