Tuesday, October 16, 2012

VB speedup tips 45 ways




1 Before compiling the project, shut down and restart the computer; BASIC.
Chore that remains in the memory variables, and they disappear when you compile the project, you can reduce the file size.

2 Remove controls such as the sub-procedure, and do not use the variable before you compile your project statement, let This will significantly reduce the size of the file.


3 When you exit the program, the END statement is used to make
QueryUnload events or End statement causes the exit code of the program, which programs do not remain in memory.


4 Please refrain from the use of the Variant variable.
If you do not specify the type when you declare a variable, VB automatically variable of type Variant to specify which variable of type Variant, very slow, so will degrade the performance of the program.


5 Sure to add the Option Explicit statement in the Declarations section of the form.
When you add the Option Explicit statement, you will not be able to use variables that are not declared, it can reduce the errors of the program.


6 Make small control.
Form name or the name of the control is added to the EXE file. Therefore, these names can reduce the size of the program by creating a small


7 Use the comment.
Comment does not add to the EXE file. Make comments instead of using a lot of the readability of the source program and increase productivity programs because maintenance is easy.


8 Pay attention to the screen resolution.
Is not always the same screen with a resolution of the user's computer.
Therefore, the program was created in the low-resolution screen with a high resolution can become a problem. Of course, vice versa.


9 Saved in text format for the project.
Stored in binary format project to increase the size of the executable file in another editor to edit, even uncomfortable, but the cause is.


10 Project;
Job or a big project to run code written in the API occurs when the program terminates abnormally. If anything, I have done so far will disappear develop a habit to save often.


11 Eliminate the temporary files in the TEMP directory.
Application to create a number of temporary files, temporary files may degrade the performance of the system. Check back often to delete, you can see the effect of improving the performance of the system. If you delete the temporary files of the programs that are running, however, the program terminates abnormally, so you should be careful.


12 If you use the Database Transaction Database can improve the processing speed.


13 Top to set the Left property, the Move method is faster than.


14 Msgbox Breakpoint is set, you can change the sequence of events when debugging.


15 Logical / Integer field to use a non-zero value, rather than to use True fast.> = 0 Then more
If ANumber Then fast.


16 Indent multiple lines, or when you want to cancel the indentation is an effective shortcuts. The Tab key to indent the selected lines, Shift-Tab key to indent selected lines off.


17 Without using an array of controls, such as in the form to create multiple controls, or press the Ctrl key is pressed, control, or Drag if the desired control icon.


18 Control quickly when you design a form and place it on the form, control, double-click the icon to make.
The control will appear in the middle of the form.


19 Not distort the contents of the picture box or form picture box or form of AutoRedraw If you set the property to True, but memory takes up a lot of factors.


20 Usually use the right mouse click when you call the object properties window, but is invoked by pressing the F2 key, Object Browse window.


21 When you toggle the Boolean variable IF ... Then ... Else than that as PreviewOn = Not PreviewOn fast.


22 Image control is much faster than the PictureBox control.


23 When checking the size of the string,> 0 Then If Len (SomeString $) Then, rather than fast.



24 Efficiently use the following code to swap two variables.

a = a Xor b: b = a Xor b: a = a Xor b

The two variables A and B of the swap.

This tip, most of the work from the bottom of the programming language.



25 A simple and efficient code for the work effectively in the low performance of the computer.


26 Can improve the speed of the basic properties of the control.
Rather than when you use a text box txtBox.Text txtBox fast, rather than when you use a label control lblLabel.Caption lblLabel fast.


27 Work when using the smallest possible size of the data type;
Long Format, Double type faster than the Integer type.


28 Instead of Debug.Print Use Breakpoints when debugging tasks,
Debugging is possible without having to stop the flow of the program effective.


29 Use the smallest possible number of controls.
If you use a lot of control causes that degrade the performance of the program.
Occupy a lot of memory and resources, but it slows down the speed of execution.


30 To draw graphics with low overhead draw graphics directly on the form.


31 Faster than to use SQL statements to use VB code using Index. SQL using VB code to run the SQL statements that have the same behavior than the index because of the slow to fast.

--- >> For I myself think it would be wrong.
SQL statement is much faster than the VB code. Excuse me, I've tried to implement a Zip automatically entered was Was the same text box, enter a name and hit the Enter key, the address and zip code to be automatically entered to Of course, the same name exists, a window where you can select when you're floating. But there was a significant time delay when you use the code here bibe. Material could keep nearly 8,000 Zip So I tried to use the SQL statement seemed very fast speed. SQL database dedicated language is in part because the database is a vital part. Note that a very small amount of data, rather bibe code can be faster.


32 A similar job control, as well as be able to reduce the amount of code written as an array, the processing speed is improved.


33 Function, the appropriate procedure code for the job you want, rather than coding directly to the function to handle the simple task of fast, but a little complicated, if you write the code as a function of prolonged, as well as easier to debug or improve speed by reducing the amount of code can


34 If you want to support multiple languages, without any action, you can create applications that can support multi-language resource files.


35 For ~ Next door to use when you use a conditional statement is the fastest.


36 In this case the speed to slow down significantly, in at once, if you put a large amount of data in the list box, the list box ReDraw because the LockWindowUndate API can be used.


37 Cause the Click event of a command button to True Value value is set to directly call a procedure that is faster than this.
Call cmdADD_Click

This command buttons, as well as other control applies equally to


38 Reads and writes to a file in the array when you do that than by reading blocks to speed fast.


39. Can be read from or written to a file in binary format to work fast, can handle a variety of tasks.


40 Is surrounded by an array of works is similar to the constant use, convenient.


41 In situations where a large amount of processing conditions gathered in front of the normal case, the abnormal cases, to collect on the back of higher readability is more efficient.


42 String is declared as a constant, and use the code to reduce the amount that you use frequently, and is more effective.


43 Simple condition checking statement If or IIF or Switch statements rather than using the Select statement that is effective.


44 Pressing Shift-F2 key to easily locate the code in the function or sub-routine, routine property.


45 To facilitate the variable type declaration, Def.

DefInt i - i start to type Integer.
DefStr s, c - that starts with s or c String variables.
Integer variables that start with k DefInt ik - i.

DefBool (Boolean)
DefByte (Byte)
DefLng (Long)
DefCur (Currency)
DefSng (Single)
DefDbl (Double)
DefDec (Decimal)
DefDate (Date)
DefStr (String)
DefObj (Object)
DefVar (Variant)

Variable assignment statement is used in more than basic

No comments:

Post a Comment