VB6 development leader

xiaoxiao2021-03-06  78

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 a half of success. The solid basic work masters the operating system, data structure, database, software engineering, and higher mathematics. These basic knowledge is In college, as long as the foundation is solid, this has reached 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, and desire to develop software, 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. Program structure cleaning, appropriately add notes to each process plus comments in the process of speech plus appropriate comments in IF ......ndif, for ... next, do ...... While, SELECT CASE ... END SELECT and other loops, branches, and conditional statements for indentation.

2. carry out controls and variable specification command recommends the following approach to naming: naming Common Controls: Control type prefix example Form frm frmMainMenu mnu mnuFileOpenLabel lbl lblHelpMessageCheck box chk chkReadOnlyCombo box cbo cboEnglishCommand button cmd cmdExitCommon dialog dlg dlgFileOpenData grid dgd dgdTitlesDate picker dtp dtpPublishedDirectory list box dir dirSourceDrive list box drv drvTargetFile list box fil filSourceADO Data ado adoBiblioFrame fra fraLanguageHierarchical flexgrid flex flexOrdersImage img imgIconImageList ils ilsAllIconsList box lst lstPolicyCodesListView lvw lvwHeadingsMonth view mvw mvwPeriodMS Chart ch chSalesbyRegionMS Flex grid msg msgClientsMS Tab mst mstFirstOLE container ole oleWorksheetOption button opt optGenderPicture box pic picVGAProgressBar prg prgLoadFileRichTextBox rtf rtfReportStatusBar sta staDateTimeTabStrip tab tabOptionsText box txt txtLastNameToolbar tlb tlbActionsTreeView tre treOrganization variable named data type prefix example string (string type) str strFNameInteger (short integer type) int intQuantityLong (long integer type) lng lngDistanceSingle (single precision floating point type ) SNG SNGAVE rageDouble (double precision floating point type) dbl dblToleranceBoolean (Boolean) bln blnFoundByte (BYTE) byt bytRasterDataDate (date type) dte dteNowCurrency (currency type and fixed-point calculations) cur curRevenueObject (object type) obj objCurrentVariant (variant type) Vnt Vntchecksum In the programming process, although the variable type is not defined, VB will automatically judge, 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 is not as good as RS.Open "Select * from table", CN, AdoPENDYNAMIC, ADLOCKBATCHOPTIMISTIC is easier to read Ø Note that the resource is used if it is used Such as RecordSet Record Set, Note that release it in the Form_unload event Ø Write high quality code, such as as little as possible, do not define the variable is integrity, do not define a Double type. One of the most common examples: DIM STR (400) AS STRING

For i = 0 to 400

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

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

NEXT

DIM STR (400) AS STRING

DIM STROUT AS STRING

For 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 that the speed of access variable is about 20 times the speed of access attribute, especially in the loop! It is also the efficiency more efficient when the database developer is writing the 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 enumeration as much as possible to [public | private] enum namemembername [= constantExpression] membername [= constantExpression] ... End Enum Advantages: Accelerate Development Speed

Ø Debut the breakpoint when debugging, use the immediate window to debug or use debug.print to the immediate window

Ø The error handling of the program If there is no good error handling, it may cause the program to spend a 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 currently 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 my personal thinking website: http://msdn.microsoft.comhttp: //www.9cbs.nethttp: //www.vbgood.comHttp: //www.dapha.Nethttp://www.21code. Comhttp: //www.vbeden.comHttp://www.applevb.comhttp://www.codestudy.nethttp://www.vbaccelerator.com/http://www.mvps.org/vbnet/HTTP: // Www.freevbcode.com/http://www.pscode.com/vb/http://www.Allapi.net The second chapter of the second chapter uses the control combination into a software VB itself provides many controls, which can be flexibly combined into a software. . The combination herein refers to a combination based on business logic, rather than casually combining. Need to have common controls: Engineering ---> component ---> Ø 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 Winsock Controls 6.0Ø Microsoft Rich TextBox Controls 6.0 General software, which can basically complete most of them. 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! User interface is an embodiment of software operability, usability, let's take an example: customer management is common functions for general enterprise management software, including customers, delete, query, print, 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: L on the left TreeView, display the customer classification, and each classification is represented by different icons. (We can classify the customer's classification, customers can maintain the classification) L On the right is a list of customers, displayed with the table, generally using the MSHFLEXGRID or the table form of the 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.gif3. If you do a function, there is no ability or time development control, you can use a third-party control. The third chapter is how to develop a master's request: Ø Skilled Using ApiaPi is a series of underlying functions, which is the system to enter the operating system core and perform 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 an ActiveX control to develop VB 6's "Add Up" ------ à selected "ActiveX Interface Wizard", let him start / load, after we can use ActiveX interface Wizard, some of the regular properties, methods, events of the control. VB installation disk and some websites have many control source, such as http://www.dapha.net, etc., etc., developing a good control is not easy, he needs the experience of programmers!

Ø COM development 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/

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

New Post(0)