Visual Basic Programming Standard (1)

zhaozj2021-02-16  43

〖First part design〗

Chapter 1 Creating Objects and Engineering Templates

The main purpose of using objects and project templates is

• Promote and encourage the reuse of the code

• Shorten the development time of new projects and existing projects

1.1 Using the object template

Although Visual Basic is equipped with many predefined object templates (the most important thing is many form templates), it is not limited to only these ready-made templates. Any standard object (such as a form or program module) created and saved with Visual Basic, can be made into object templates. Many subfolders in the Template folder are included, and each object with a template has a subfolder. Visual Basic View the corresponding subfolder and add each object in the subfolder to the ADD dialog box as a template icon. If the file in the subfolder is not a correct type, the file is ignored.

1.2 Using Project Templates

From the current situation, the focus of software development is basically placed on the reuse of the program. Programming with objects has become a hot topic for programmers. In fact, the object is completely established for reuse of the code. Only when certain parts or all of the existing objects are used in order to make full use of previous development results, the development time and test time can be shortened.

1.2.1 Visual Basic Project Template Overview

The project template is a frame template containing some basic objects (such as forms or program modules), or it is a half-complete application that contains complex code such as multi-document interface (MDI) front-end program.

1.2.2 Creating a custom project template

Since each module (including form module) should have a complete error tracking (as I am in Chapter 6), the corresponding error handling characteristics should be added to each object template. Its purpose is to make each object template as complete as possible. Whenever these objects must complete the same job whenever an object based on a common template is added, then this work should be done in the template file itself.

1.3 Customize the behavior characteristics of the template

1.3.1 Activation of Templates and Cancel Templates

To cancel an activation state of an object template, select Options from the Tools menu, then click the Environment tab, open the Visual Basic's Options dialog.

1.3.2 Setting Template folder

The folders set in the Templates Directory on the Environment tab in the Options dialog are the parent folder, and Visual Basic can look up the object template.

1.4 Programming Principles

1.4.1 Do not hardly encode the value of a particular application in the object template or the value of a particular component

Basically, three methods can be used to ensure that the template objects use and displayed are data for the item where the object is located:

1. The properties of the Add object are referenced at possible.

2. Provide corresponding functions and properties, which are called to set the values ​​in the object.

3. Use a set of common global constants (if absolutely necessary, some variables can also be set).

Use the parameters of the public process, perhaps the best way to share project data with template objects.

1.4.2 Provides a wide range of annotations in the object template, especially if you need to modify, add notes

In all object templates, you should use a unified method to add a comment so that the template-based object is incorporated into the project.

You can save time and effort. The more instructions recorded in the object template (notes), the objects can be used more efficiently for other items.

转载请注明原文地址:https://www.9cbs.com/read-27368.html

New Post(0)
CopyRight © 2020 All Rights Reserved
Processed: 0.041, SQL: 9