Shutting Down the Visual Basic Editor

     

When you've completed your VBA chores, you can shut down the Visual Basic Editor by using either of the following techniques:

  • Pull down the File menu and select the Close and Return to Application command, where Application is the name of the program you're running (such as Microsoft Excel).

  • Press Alt+Q.

The Absolute Minimum

This chapter got you started down the road to writing your own macros by showing a few necessary techniques. If you feel a little uncertain about anything you read here, that's perfectly natural because I've been telling you the how of creating macros without also telling you the what . As I've said, the specifics of the VBA language will be covered in detail throughout the rest of the book, particularly the next four chapters.

Everything you learned in this chapter will become second nature to you before your VBA education is complete. However, there are a few things you should be sure you know cold before moving on.

First, you need to know the basic structure of a Sub procedure, which is allowed to modify its environment, but can't return a value:

 Sub  ProcedureName  (  argument1, argument2  , ...)     [  VBA statements  ] End Sub 

Similarly, you need to know the basic structure of a Function procedure, which can't modify its environment, but can return a value:

 Function  ProcedureName  (  argument1, argument2  , ...)     [  VBA statements  ]  ProcedureName  =  returnValue  End Function 

Secondly, I'd like to impress upon you the advantages to taking a neat, orderly approach to your programming. Humans can and do thrive in messy environments, but we're many times smarter and infinitely more intuitive than any macro. Procedures live in a world of strict and unyielding logic, and programming is always many times easier if you supplement that logic with a sense of order. Fortunately, there are only two things you need to do to achieve most of the order you need to be a successful programmer:

  • Don't skimp on the comments. Any procedure will be much easier to read if it is sprinkled liberally with comments throughout the code. Also, adding comments as you go is a great way of getting a grip on your own thoughts and logical leaps as you go.

  • Indent your code. Again, this is mostly a readability exercise, but as you'll see later in the book ” especially when you learn fun stuff such as programming loops in Chapter 6 ”properly indenting your code can prevent many errors.




Absolute Beginner's Guide to VBA
Absolute Beginners Guide to VBA
ISBN: 0789730766
EAN: 2147483647
Year: 2003
Pages: 146

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net