Previous page Previous     TOC Contents     Next pageNext


LESSON 1b - How to master the interface





Any program can stand to be improved, even mine!
But there's a technique to use when building a bigger and better application - you do it step-by-step.





How to improve the application

Assuming that you're a beginner with VB, here's the development technique I recommend for you:

  • write the simplest program that you understand and make it work - even if it doesn't have colour or fancy fonts, test it and then save it;

  • make a copy of your previous working program and code one or two improvements in the copy - if you become stuck and can't recover, destroy the copy, go back to the previous version, make a new copy and start again;

  • repeat for every improvement you make, using small steps so that if something does go wrong it's easier to identify the source of the problem (if you made 12 corrections in a program and then it doesn't work, how will you know which of the changes is causing the problem?)

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 improvement

Another 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.







To download the improved sample program and study it, click here:
FootScoreboard2.zip








If you haven't found the Visual Basic resource you're looking for,
use our Google Search box for more information.

Google