Tuesday, August 14, 2012

Tips VB 45 kinds of speed




A. Before compiling the project, basic exit and restart your computer make.
And, when you compile the project, trinkets variables that remain in the memory is gone, you can reduce the file size.

Two. Before compiling the project, unused variables and sub-procedures, the Declaration, like the control dislodge. This will significantly reduce the file size.


Three. Use when you exit the program END statement.
The end of the program code or QueryUnload event using the End statement, the program remains in memory, so do not give.


Four. Variant variables do not.
When you declare a variable if you do not specify the type of Basic automatically to the variable of type Variant, which specifies, Variant variable of the type of program is very slow, so they are detrimental to performance.


5 Form have to add the Option Explicit statement in the declaration.
When adding the Option Explicit statement, variables are not declared unusable, so the program can reduce the error.


6. Make small control people.
Pomyireumyina control is added to the name of the EXE file. So far, these names can create a program to reduce the size of.


7 Use a lot of comments.
Comment does not add to the EXE file. Instead, the program will use a lot of comments on the readability of the source increases, so productivity and maintenance program is easy.


Eight. Pay attention to screen resolution.
Your computer does not always have the same screen resolution.
Therefore, programs that are created by low-resolution screen with high resolution can be a problem. Of course, it is vice versa.


Nine. Make a project saved in text format.
The project is stored in binary format, begin to edit in another editor, nor inconvenient, to increase the size of the executable file is the cause.


10 Save your project often make.
Large projects or operations, API to execute code when the program is written in an abnormal situation occurs that is shut down. Until now, the code worked on this case to disappear, so save often foster the habit.


11 TEMP directory to get rid of temporary files.
Multiple applications create temporary files, temporary files on the system can also cause performance degradation. Check back often to give the performance of the system and remove the improvement can be seen. However, the running of the program and delete temporary files, the program terminates abnormally, so be careful.


12 Using Database Transaction Database can improve processing speed.


13. Move method Top, Left faster than setting the properties.


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


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


16. Indent multiple lines, or by using keyboard shortcuts to undo the indentation is effective. Tab key to indent the selected line, Shift-Tab key to indent the selected lines are turned off.


17. Without using a control array, to create multiple form controls, such as control, or press the Ctrl key is pressed, or the desired control is done by Drag the icon.


18. When designing a form to drop quickly to the control form, control, make double-click the icon.
This form of control will appear in the middle.


19. Picture night AutoRedraw property to True or by setting the form's picture box or the contents of the form will not be distorted, but it takes a lot of memory will often factor.


20 When you call the object properties window, right-click usually used, but, F2, press [Object Browser window is invoked.


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


22. Image control is much faster than the PictureBox control.


23. When you examine the size of the string,> 0 Then instead If Len (SomeString $) Then faster.



24. To swap two variables effectively uses the following code.

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

This swap two variables A and B are

This tip will work on most of the peurogeuraemit language.



25. A simple and efficient code in the low-end computers to operate effectively.


26. Using the basic properties with the control can improve the speed.
When you use a text box rather than txtBox.Text txtBox fast, when you use a label control, rather than lblLabel.Caption lblLabel faster.


27. When working with small-sized data types as possible should be used.
Long data type, or, Double format is faster than the Integer type.


28. When debugging, back up job, Breakpoints Use Debug.Print instead.
Without stopping the flow of a program of effective debugging is possible.


29. Use the smallest possible number of controls.
When you use a lot of control of the program will cause a performance degradation.
Nor take a lot of memory and resources, the speed of execution is slower.


30. To draw graphics with less overhead, draw graphics directly on the form is


31 Rather than using a SQL statement using the Index is to use VB code faster. SQL is the same behavior that is slower than running the SQL statement using the index is faster to use VB code.

--- >> Myself for this part is wrong, I think.
VB code is much faster than the SQL statement. For instance, I automatically enter the zip code was never trying to implement. In the text box and press enter to dongyireum hit address and postal code to be automatically entered was one. Of course, if there are to choose the same name tteuguyo window. But here a considerable time lag when using the code Biberaj were Zip Code is little data about 8000 anyway. So I tried to use the SQL statement is a lot very fast. Because the database language SQL, only the necessary part of the database is a part. Note that in a very small amount of data may be sooner rather than Biberaj code.


32. Similar to work by writing an array of controls to reduce the amount of code, as well as processing speed is improved.


33. To handle simple tasks, functions and tasks, rather than the code directly into the desired procedure to code faster, but a complex or prolonged as a function by writing code debugging easier, as well as improve the speed by reducing the amount of code can.


34 If you want to support multiple languages ​​using resource files, you need to do anything to support a multi-lingual applications can be made.


35. For ~ Next door when using a conditional statement is the fastest.


36. Large amounts of data in the list box to put together a list box ReDraw case, because the rate was significantly slowed down, for this case, you are LockWindowUndate API.


37 Command button's Click event to raise, Value value is set to True, you come across, this procedure is to call directly rather than fast.
Call cmdADD_Click

This, as well as command buttons, other controls are applied equally.


38. When you write a file to read from the array, rather than in blocks with hanissik to read fast.


39. When two formations like read and write files to work fast, and can handle a variety of tasks.


40. Similar action by enclosing the array using a constant that can be used conveniently.


41. In situations where large amounts of processing conditions in front of the normal case, gathering in the back to collect the unusual case, readability is becoming more efficient.


42. Frequently used to declare a constant string, you can reduce the amount code, it is more effective.


43. If the door or if a simple conditional test, Select Switch munbodaneun IIF statement is effective to me.


44. Function or subroutine in the code, easy to find the property routines are pressing Shift-F2.


45 To make the type of the variable declaration, Def is done using.

DefInt i - i would like to start with all of type Integer.
DefStr s, c - s and c are all String type variable to begin with.
DefInt ik - i k in both the Integer type variable to begin with.

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

Or more basic variables used in the directive is

No comments:

Post a Comment