Unanswered: Error Prevention Techniques in VB Programming (I)
There are techniques which helps a programmer to reduce prevent programming errors as much as possible. They are based on Software Engineering principles and Software Quality Assurance concepts.
They do not reduce logical errors because that depends on the programmer.
Rather, these techniques only provide the structures which helps the programmer to write programs with as little bugs as possible.
A VB program, like other programs, consists of Data and Program Codes.
All variables should be declared and have meaningful names.
Program Codes :
They should be easy to read and understand. They should allow you to proof that they are correct with CONFIDENCE. Ideally, the program codes should be layered - this allows you to proof correctness layer by layer. If you can proof that an upper layer is correct, then the subsequent (more CONCRETE) layer has a better chance to be bug free than otherwise. They should be highly maintainable. Doing changes in hard-to-maintain programs is more likely to result in MORE programming errors than maintainable ones.
(a1) Variable declaration should be enforced using "Option explicit";
(a2) Give variables meaningful names;
(b1) Put modularity into your programs;
(b2) Put layers of abstraction into your programs ;
(b3) Procedures/functions should have HIGH cohesion;
(b4) Use PARAMETERS as much as possible for inter-procedure communication, to achieve LOW Coupling amongst procedures/functions ;
(b5) Global variables should be AVOIDED as much as possible;
(b6) Try to use built-in functionalities of the programming language as much as possible;
(b7) Try to group procedures/functions by tables as much as possible, e.g. using Class modules.
All procedures/functions which are related to a table will be found in a single location.
In this way, procedures/functions will be LESS duplicated, and ,as result, maintenance will be easier.
(b8) If data structures are being used, then there should be some procedures/functions designed to process them and they should
be located in the appropriate module.