Here are some things to do which will bear dividends later:
Use 'Option explicit' at the top of every code module. This forces you to declare each variable that you use in your code. This may be a pain at first but it avoids confusion in the code later.
Comment your code. If you start a line of code with an apostrophe that line will be ignored at run time. This means you have the opportunity to write comments on your code as you go. This may not be important at the time but when you come to recycle the code in a years time good commenting will make your life sooo much easier! As a guiding rule if you have as much comment as code that is probably no bad thing.
Keep it short: Break your code down into small modules each with a seperate task. It is better to have ten modules each doing one specific thing rather than one module with 150 lines of code. This means error checking and re-using code will be much simpler later.
Make it recyclable: It will save you a massive amount of time if you can re-use elements of your code many times in different applications rather than re-writing code from scratch. It is worthwhile spending a little more time coding at the outset to make modules easy to use in different applications.
Have a naming convention: Whenever you write something in VBA you will end up creating 'things'. (I'm trying really hard to avoid phrases like 'Object Orientated programming') Have a system for the way that you name 'things'. It will help lots later.
Make names descriptive: By the time you are 18 hours into your development session it will really help if you have rational and logical names for the 'things' that you are working with.
There are many more but that's enough for now.
Thursday, 22 January 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment