© 2007 The Smart Method Ltd
89
Session Five: Professional
Grade VBA
In the previous session we covered the bare bones of the VBA language.
Unfortunately the code you have written so far is well below professional
standards. It is, however, the type of code that many beginner and self-
taught programmers might write.
So what’s wrong with the code. You’ll find out in this session when we
migrate our low-grade code into something a professional would be
proud of.
In order to write high quality code there are a few new concepts we need
to take on board. You’ll learn it all in this session and will then be able to
write robust, bug-free, crash-proof code that will be wonderful to work
with.
Session Objectives
By the end of this session you will be able to:
Understand data types
Understand and implement strong typing
Understand and implement explicit variable declaration
Understand arguments
Understand functions
Understand ByRef and ByVal argument types
Set and retrieve form control values from within VBA
Understand scope
Implement error handling
Use the help system and the object browser
The most important thing I have learned over the years is the
difference between taking one's work seriously and taking one's self
seriously. The first is imperative, and the second disastrous.
Dame Margot Fonteyn (1919-1991), British ballet dancer
Session5
5