Word Document Properties


Part II: Learning the Ropes



Download 8,82 Mb.
Pdf ko'rish
bet61/207
Sana16.03.2022
Hajmi8,82 Mb.
#496217
1   ...   57   58   59   60   61   62   63   64   ...   207
Bog'liq
VBA For Dummies 5th Ed.pdf ( PDFDrive )

Part II: Learning the Ropes 
08_046500 ch03.qxp 12/5/06 5:34 PM Page 60


just can’t return a value — only a 
Function
can do that. However, you can
use arguments as one method for modifying information by using a 
Sub
(see
the example in the upcoming “Writing Your First Function” section). A second
method relies on global variables (see the example in the later “Defining the
effects of scope” section).
Many VBA users also use the 
Sub
as a means of breaking up code. Instead of
creating code that goes on for miles and miles, using several 
Sub
s can break
up the code into page-sized pieces. Using this method makes the code a lot
easier to read.
Using Functions
You might not see a use for the 
Function
after spending some time working
with the 
Sub
. However, not every problem is a screw requiring the use of a
screwdriver or a nail in search of a hammer. You use a 
Function
for different
problems than a 
Sub
can answer. In most cases, there’s definitely a correct
answer to using a 
Function
or a 
Sub
. For example, you always use a 
Sub
when you want to access program code from within the host application, and
you always use a 
Function
when you want to perform a calculation with a
return result.

Function
always returns a value, which makes it different from a 
Sub
.
For this reason, you can write functions that contain code that you plan to
repeat a lot within a program. To process a list of names, you might create a
Function
to process each name individually and then call that 
Function
once for each name. The 
Function
can provide the processed information
as a return value. In Chapter 5, I describe how to create repeating code using
structures such as 
Do...Until
.
You can also use a 
Function
for public code that you don’t want to list in
the Macro dialog box. You normally don’t see a 
Function
listed in the Macro
dialog box — this dialog box usually lists only 
Sub
s.
Modifying the project settings
So far, you’ve used VBA without configuring many of the options, and the
examples have relied on defaults that VBA normally uses. Most of the VBA
program levels have some type of configuration, including the project. In this
section, I describe the various project-setting options.
61

Download 8,82 Mb.

Do'stlaringiz bilan baham:
1   ...   57   58   59   60   61   62   63   64   ...   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