Powerful PowerPoint for Educators: Using Visual Basic for Applications to Make PowerPoint Interactive
Download 1.37 Mb. Pdf ko'rish
|
2.2. Powerful PowerPoint For Educators
- Bu sahifa navigatsiya:
- Cap i tal iza tion
An Ounce of Prevention
As you write your code, you can use several techniques to help you catch bugs as you type. These techniques will not pre vent all bugs, but they will cut down on the num ber you have to find later. If you are perfect and never make mistakes, these techniques won’t affect any thing. The techniques are for hu man eyes; the computer will be able to run your code without them. But for those of us who are not perfect, our hu man eyes need all the help we can get to catch bugs or pre vent them from happening. Cap i tal iza tion You might have looked at some of the ex amples and won dered why certain things were cap italized in certain ways. Some of it is part of the technique to pre- vent bugs, and some of it is forced upon you by VBA. There are five kinds of things you can type into the VBA Editor: 1. Comments 2. Text between quotes 3. Variable names 4. Pro ce dure names 5. VBA stuff (built-in func tion names, pro cedure names, ob ject names, etc.) Comments can be cap italized any way that you like because they are for you to read. Pay close at tention to capitalization of text be tween quotes be cause that will usually be dis played for your students, but for the pur poses of de bug- ging, it doesn’t mat ter how you cap italize it. Cap italization of the last three items can be important for debugging. In this book, I have used the fol lowing con vention: Variable names be gin with a lowercase let ter; and procedure names be gin with an up percase let ter. Furthermore, since variable names and procedure names can not con tain spaces, any new word in the name be gins with an up percase letter. This is a convention, a technique, a trick. I could have used yourName in stead of YourName and UserName in stead of userName . It would have worked fine. How ever, if you use this convention, you can look at your code and always tell whether a name 162 De bug ging Tips re fers to a vari able or a pro ce dure by look ing at the cap i tal iza tion. Cap i tal iz ing the first letter of each sub sequent word in a variable or pro cedure name simply helps you read it more easily. You want to be able to read the names because you picked names that make sense to you. You should be able to tell immediately that the following are vari ables, and you prob ably even have a reasonable idea of what in formation they hold: Download 1.37 Mb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling