Powerful PowerPoint for Educators: Using Visual Basic for Applications to Make PowerPoint Interactive


Dim statements. Du pli cate Pro ce dures


Download 1.37 Mb.
Pdf ko'rish
bet176/191
Sana08.05.2023
Hajmi1.37 Mb.
#1442581
1   ...   172   173   174   175   176   177   178   179   ...   191
Bog'liq
2.2. Powerful PowerPoint For Educators

Dim
statements.
Du pli cate Pro ce dures
Just like VBA doesn’t know what to do when you have two variables with
the same name, it doesn’t know what to do when you have two pro cedures with
the same name. You might have been playing around with the ex amples in this
book and accidentally wrote two 
YourName
pro cedures. They might be exactly
the same or dif ferent, but if they have the same name, noth ing will work. Fig ure
out which pro cedure does what you want and delete the du plicate. Or, if the two
procedures are re ally supposed to be do ing dif ferent things, give one of them a
different name. You might also want to add a com ment to ex plain what each
procedure does.
Note that variables and procedures are not al lowed to have
the same name. If you give a procedure the same name as a
variable, it will not work.
Ex tra End
 Sub
The VBA Ed itor is nice. It never requires you to type 
End Sub
. When you
hit the En ter key af ter typing a 
Sub
line, the ed i tor au to mat i cally types the
End
Sub
. Most of the time, this is a good thing. Occasionally, it is not, such as when it 
leads to your code hav ing too many
End Sub
lines. Since you don’t type the 
End
Sub
lines, it is easy for ex tra ones to be added to your code.
If your code stops working, check for extra
End Sub
lines. They might be
at the end of the mod ule or at the end of a procedure. Usually they’re in a place
that is not showing on your screen, so you’ll have to scroll to see them. De lete
the extra
End Sub
, and your code might work again.
Com mon Bugs 169
!


The For got ten Dim
In some cases you don’t need to de clare variables, but if you want a variable
to re member something later, you must de clare it at the be ginning of the mod ule.
It is easy to for get to do this. If, for example, you forget to declare

Download 1.37 Mb.

Do'stlaringiz bilan baham:
1   ...   172   173   174   175   176   177   178   179   ...   191




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling