Word Document Properties


Chapter 5: Creating Structured Programs



Download 8,82 Mb.
Pdf ko'rish
bet117/207
Sana16.03.2022
Hajmi8,82 Mb.
#496217
1   ...   113   114   115   116   117   118   119   120   ...   207
Bog'liq
VBA For Dummies 5th Ed.pdf ( PDFDrive )

Chapter 5: Creating Structured Programs
10_046500 ch05.qxp 12/5/06 5:35 PM Page 129


You can use this statement for a number of purposes, but generally it’s easier
and faster to use the 
For...Next
statement for standard code. You must
use the 
For Each...Next
statement with arrays and collections. See
Chapter 9 for details on using arrays and collections.
Redirecting the Flow by Using GoTo
You might run into situations where the existing program flow doesn’t work,
and you have to disrupt it to move somewhere else in the code. The 
GoTo
statement provides a means of redirecting program flow. Used carefully, the
GoTo
statement can help you overcome specific programming problems.
Unfortunately, the 
GoTo
statement has caused more problems (such as creat-
ing hard-to-understand code and hiding programming errors) than any other
programming statement because it has a great potential for misuse. Novice
programmers find it easier to use the 
GoTo
statement to overcome program-
ming errors rather than to fix these problems. Always use the 
GoTo
state-
ment with extreme care. Designing your code to flow well before you write it
and fixing errors when you find them are both easier than reading code with
misused 
GoTo
statements.
Using the GoTo statement correctly
The 
GoTo
statement provides the essential service of helping you redirect pro-
gram flow. Before you use the 
GoTo
statement, ask yourself whether there’s
some other means of performing the redirection, such as using a loop. If there
isn’t any other way to perform the programming task efficiently, using a 
GoTo
statement is acceptable. Listing 5-9 shows an example of correct 
GoTo
usage.
It’s an update of the example shown in the earlier “Using the Select Case state-
ment” section of this chapter. (You can find the source code for this example
on the Dummies.com site at 
http://www.dummies.com/go/vbafd5e
.)

Download 8,82 Mb.

Do'stlaringiz bilan baham:
1   ...   113   114   115   116   117   118   119   120   ...   207




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

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish