Making a Preparation Before Coding

Other topics about Operation Basics

A Project and Three Type of Modules

Project Explorer displays a list of files (modules) that are used in the E5071C VBA. This section describes a project composed of a number of files (modules) and three types of modules ("user form", "standard," and "class"). Each type of module serves its own purposes as described below.

Project

When you develop an application within the E5071C's VBA environment, you use a number of VBA program files (modules), and manage them as one project. The project is saved with the file extension ".vba".

User Form

A user form contains controls such as buttons and text boxes. You can code event-driven procedures that are invoked when a particular event occurs on a particular control, thereby creating a user interface. The user form is saved with the file extension ".frm".

Standard module

A standard module contains a collection of one or more procedures (subprograms enclosed between Sub and End Sub). One typical use of a standard module is to contain shared subroutines and globally called functions. The standard module is saved with the file extension ".bas".

Class Module

A class module contains both data and procedures and acts as one object. Once you have created a class module that serves as an object, you can create any number of instances of that object by naming each instance as an object variable. While each procedure must be unique in a standard module, you can have multiple instances of an object created through a class module. The class module is saved with the file extension ".cls".

 

Displaying a Code Window

The code windows appear on the Visual Basic Editor by inserting the modules in a project. You can do coding (programming) on this code windows practically.

The E5071C's VBA environment does not allow you to manage multiple projects. When the current project is existing in the Visual Basic Editor by loading the saved project file, you can replace the current project with a new project by the following method from the E5071C measurement screen.

  1. Macro Setup > New Project

  2. When you replace the current project with a new project, the message whether or not the current project is saved may appear. If you want to save the project, click Yes button to display a dialog box for saving. For saving the project, see Saving a Project.

Inserting the User Form

Within Visual Basic Editor, do one of the following to add a user form to your project.

  1. On the Insert menu, click UserForm.

  2. On the toolbar, click "Insert User Form/Standard Module/Class Module/Procedure" icon, and click UserForm.

  3. In Project Explorer, right-click the "VBAProject" icon, and click Insert > UserForm.

  4. Adding a user form does not automatically open the code window for that user form. To open the code window, click the "Display Code" icon on Project Explorer in the following figure or double-click a control placed on the user form.

Adding a user form

Inserting the Standard Module

Within Visual Basic Editor, do one of the following to add a standard module to your project.

  1. On the Insert menu, click Module.

  2. On the toolbar, click "Insert User Form/Standard Module/Class Module/Procedure" icon, and click Module.

  3. In Project Explorer, right-click the "VBAProject" icon, and click Insert > Module.

Adding a standard module/class module

Inserting the Class Module

Within Visual Basic Editor, do one of the following to add a class module to your project.

  1. On the Insert menu, click ClassModule.

  2. On the toolbar, click "Insert User Form/Standard Module/Class Module/Procedure" icon, and click ClassModule.

  3. In Project Explorer, right-click the "VBAProject" icon, and click Insert > ClassModule.

Deleting Modules

You can delete any unnecessary module from the project within Visual Basic Editor. The following procedure assumes that you want to delete a class module named "Class1".

  1. In Project Explorer, click the "Class1" class module under the "Class Modules" icon to highlight it.

  2. Delete the "Class1" class module using one of the following methods:

    1. On the File menu, click Remove Class1....

    2. Click the right mouse button, and click Remove Class1....

  3. When you are prompted to confirm whether to export (save) "Class1", click No. Alternatively, you can click Yes if you want to save the module.