VB6 development pilot (1)

zhaozj2021-02-17  47

VB6 development leader

Visual Basic 6 is known in the world with a friendly and easy-learning visualization development environment, and has become the preferred language of learning computer programming. The university class, training institutions have included her into the teaching content. Ask many just learning programming people, what will they? They usually answer: "I will vb!" However, you have to let them solve some practical problems with VB, we don't say large software, it is a small incoming memory, they will feel hard! The design is unreasonable, BUG is constantly, the changes in customer needs, the software is inevitably changed, and it may be trapped into "quagmire" in the store software! If a large software can be developed, you can imagine the business process, the functional module is complex, the user needs diversify, and many development teams may fall into this "tar" ("Moon Myth".

The author used VB for three years of software development, participating in the design and developing more than a dozen software products. He has hosted some large projects for the Calculation Center of the Tianjin Foreign Trade and Economic Cases Committee, Tianjin General Software Co., Ltd., and summarizes VB development. If you are using VB, I am willing to help you:

The first chapter is a good start is half of success.

Ø Solid basic skill

Master the knowledge of operating systems, data structures, databases, software engineering, and higher mathematics, these basic knowledge is in college, as long as the foundation is solid, this has achieved this requirement. If a high school student, there is a great enthusiasm for software development, so you have to take great practice.

Ø Interest is the best teacher

If you are interested in programming, you are eager to develop, master a programming language is the most important! In the course of the learning program, there will be a lot of difficulties. If you don't have interest and patience, it's a bad procedure!

Ø Develop good programming style and habits

1. The program structure is clear, appropriately add notes

Add a comment for each process

Additional comments in the process

Index, branch, and conditional statements such as if ......ndif, for ......, do .......................

2. Specify control and variable commands

Recommended in the following ways:

In the programming process, although the variable type is not defined, VB will automatically determine, low efficiency, and try to define variables during programming. It is best to add an OPTION Explicit statement at the top of the module so that the variable must be defined.

Ø Improve the readability of the code

such as:

Rs.Open "Select * from table", CN, 1, 1

It is better to read it is easier to read if rs.open "select * from table", cn, adopendynamic, AdlockbatchOptimistic is easier to read.

Ø Pay attention to release resources

If you use the RECORDSET recordset, pay attention to the Form_unload event release it

Ø Write high quality code

For example, try to define the variant variable as much as possible, do not define a Double type when you know that the variable is intellectual.

One most common example:

DIM STR (400) AS STRING

For i = 0 to 400

STR (i) = "

First

"& I &"

A

"

TEXT1.TEXT = TEXT1.TEXT & STR (i)

NEXT

DIM STR (400) AS STRING

DIM STROUT AS STRINGFOR I = 0 to 400

STR (i) = "" "& I &" one "

Strout = Strout & Str (i)

NEXT

TEXT1.TEXT = STROUT

The above two segments, the first code loop TEXT attribute, the second segment code is accumulated with the variable strout, and finally assigns the TEXT attribute. Although the two codes have been the same result, the speed of the former cannot be compared to the latter. To know the speed of access variables is about 20 times the speed of access attribute, especially in the loop!

Still is that the database developers should consider when writing a stored procedure! For example, using the cursor cycle to read the table, more than 10,000 records are very slow! All said, we must emphasize the preparation of high quality code!

Ø Try to use with .... end with when repeating the properties of an object

Ø Write the function of the frequently used modules to improve the versatility of the program and maintainability

Ø Use enumeration as much as possible

The enumeration format is [public | private] enum namemembername [= constantExpression] membername [= constantExpression] ... End Enum

The advantage is: Accelerate the development speed

Ø debugging

Obpel when debugging

Use the immediate window to debug

Or output to the immediate window with Debug.print

Ø Procedure error handling

If there is no good error handling, it may cause the program to quit the wrong mistake! We need to add an on error statement during the error handling. Of course, you can also write a global error handling module!

Ø Master a database development language

At present, most software development uses a database, and more mainly include Access, SQL Server, and Oracle.

Ø Look at MSDN, multi-Internet access.

MSDN is an indispensable place to programmakers, websites and forums are also a good place to solve problems.

The following is a good website I personally think:

http://msdn.microsoft.com

http://www.9cbs.net

http://www.vbgood.com

http://www.dapha.net

http://www.21code.com

Http://www.vbeden.com

http://www.applevb.com

http://www.codestudy.net

http://www.vbaccelerator.com/

http://www.mvps.org/vbnet/

http://www.freevbcode.com/

http://www.pscode.com/vb/

http://www.allapi.net

Chapter II combined with control into a software

VB itself provides a number of controls that can be flexibly combined into a software. The combination herein refers to a combination based on business logic, rather than casually combining.

Need to master common controls: Project ---> Parts --->

Ø Microsoft Windows Common Controls 6.0

Ø Microsoft Windows Common Controls 2-6.0

Ø Microsoft Common Dialog Controls 6.0

Ø Microsoft FlexGrid Controls 6.0

Ø Microsoft Hierarchical FlexGrid Controls 6.0ø Microsoft DataGrid Controls 6.0

Ø Microsoft Internet Controls, INTROLS

Ø Microsoft Winsock Controls 6.0

Ø Microsoft Rich TextBox Controls 6.0

The general software is substantially completed by the above controls.

1. First, we must learn the use of menus, toolbar, common controls, if you want to do a floating toolbar, you can use Toolbar and Coolbar (Microsoft Windows Common Controls 3-6.0 with a Coolbar), right-click Coolbar -> Properties ---> Belt -> Son -> Join a Toolbar so that the toolbar can move!

2. Second, we must master the properties of the above controls, the use of methods. The interface of the software is combined by some controls! The user interface is an embodiment of software operability, usability, let's take a look at an example:

Customer management is a common function of general enterprise management software, including customers, delete, query, printing, maintenance, etc., how to design this interface? Generally speaking, companies customers generally have classifications, divided into direct customers, distribution customers, etc., some companies are divided into domestic customers, foreign customers, etc., different enterprises have different integration.

Then we can design this:

l On the left TreeView, displays the customer classification, each classification to use different icons. (We can classify the customer's classification, customers can maintain the classification)

l On the right is a list of clients, displayed with tables, generally using MSHFLEXGRID or list forms of ListView.

l When you click on a node of the left TreeView, the right table is refreshed, and the current classification is displayed.

l Above the form, add a toolbar, mainly add, delete, query, print, exit buttons.

l On the right of the client, we can also do a right-click menu, you can implement editing (pop up a new window, edit the currently selected customer, you can print the current customer profile in the new window), delete, etc..

This interface design is basically molded! If you are familiar with the database SQL, this feature is easy!

The interface is similar to this: http://www.gci-corp.com/images/fy.gif

3. If you have a function, there is no ability or time development control, you can use a third-party control.

The third chapter is how to become a master

Ø Proficiency in using API

The API said that the bottom is a series of underlying functions, and the system is provided to the user to enter the operating system core, and advanced programming. If you want to draw a class, then you have to learn how API (Application Program Interface, Windows Application Programming Interface) is programmed. Don't understand the API, you can't make a master.

1) Use the API, we can extend the functionality of the VB standard control. Obviously, the controls in Windows provide a number of properties than the controls in the VB. Perhaps Microsoft believes that a programmer with VB will never touch those properties.

For example, a TextBox control, less attribute gets the number of text it contains, we can use SendMessage to get: Private Declare function sendMessage lib "user32" Alias ​​"SendMessagea" (Byval Hwnd As Long, _

Byval WMSG As Long, _

Byval wparam as long, _

LPARAM As Any) As Long

Const em_getlinecount = & hba

Public Function Linecount (TxtBox As Textbox) As long

Linecount = sendMessage (txtbox.hwnd, em_getlinecount, 0 &, 0 &)

END FUNCTION

Private submmand1_click ()

Msgbox LineCount (Text1)

End Sub

Ø Master ActiveX control development

Under the "Add Up" menu of the VB 6, there is a "Out-User Manager" ------ à selected "ActiveX Interface Wizard", let him start / load, after we can use the ActiveX interface wizard to generate controls Some frequent attributes, methods, events.

VB installation disk and some websites have many control source, such as http://www.dapha.net, etc.

Of course, developing a good control is not easy, he needs to accumulate the experience of the programmer!

Ø Can develop COM

Com provides the general infrastructure required by enterprise applications, allowing programmers and users to focus on business logic instead of infrastructure.

Advantages: Separate the components as universal, compile time characteristics and runtime characteristics, compatible with previous COM components, transparency of customers, and components.

Everyone can refer to:

http://www.icst.pku.edu.cn/compcourse/

Ø Mixed programming of multiple languages

Every development language has its own advantages and disadvantages, sometimes we have to make a long-term addition. A good developer wants to be a thing, generally not limited by the development tool. They always look for a good solution. Of course, they are not a pursuit of technological excellence. We need to consider whether it is feasible from time and money! If the VB developer will also vc, it will be like a fish!

summary:

If you have already described the above requirements, developing large software, has a certain experience, can generally become the technical backbonate in the development team. At this time, you need to further improve. The general project manager's position, the employee within ten people, such a position can still be gone! Don't underestimate this position, it is a good opportunity for exercising your management capabilities! At this time, we have to learn how to lead the team to develop software!

Next foreland:

Chapter IV System Analysis and Architecture

Chapter 5 leads the team to carry out software development

'********************************************************** *************

'Author: Li Honggen

'E-mail: lihonggen0@163.com lihonggen0@gci-corp.com

'Personal column: http://www.9cbs.net/develop/author/netauthor/lihonggen0/

'If you need to quote, please refer to the place! 9CBS Forum VB Welcome!

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

New Post(0)