Avoid repeating code!In our FootScoreboard example, there is one occasion where there are several lines of code repeated.OK, so it's only a few lines but, in a large program that can happen a lot and it is very time-consuming both to create the code and the to maintain it. ![]() The way to correct that is to take all the code that repeats and put it into a separate procedure. A procedure is identified by the Private Sub ... End Sub lines. Then, whenever you have to execute the code, call the procedure simply by writing its name. ![]() A second improvementAnother thing we usually need in a program is a re-initialize button.After one loop of the program, in this case one match, we usually want to clear all the data and start over. For that we'll create a Clear button on the form. ![]() But, we'll notice that what we do with the Clear button is in fact the same thing we do when we load the form in the first place. So, we'll use the procedure technique to simplify the code. ![]() selamat mencoba ............ semoga bermanfaat............... If you haven't found the Visual Basic resource you're looking for, |
Improving the application
Sabtu, 14 Mei 2011
Langganan:
Posting Komentar (Atom)







0 komentar:
Posting Komentar