Word Document Properties


Part I: An Overview of VBA



Download 8,82 Mb.
Pdf ko'rish
bet44/207
Sana16.03.2022
Hajmi8,82 Mb.
#496217
1   ...   40   41   42   43   44   45   46   47   ...   207
Bog'liq
VBA For Dummies 5th Ed.pdf ( PDFDrive )

Part I: An Overview of VBA 
06_046500 ch02.qxp 12/5/06 5:33 PM Page 36


The 
MsgBox
function is capable of doing more than the Chapter 1 example
shows. First, the function can return a 
Result
that shows which button the
user selected. The 
Result
variable holds the selection information so that
you can use it in other ways. You can also tell 
MsgBox
which buttons to dis-
play and to provide a title. Here’s a more advanced version of the 
MsgBox
function that I use in Chapter 1 — type this line directly beneath the 
‘Display the message box
comment:
Result = MsgBox(“Click a Button”, vbYesNoCancel, “A
Message”)
This code tells VBA to display a message box with 
“Click a Button”
as
the text and 
“A Message”
on the title bar. The message box includes the
Yes, No, and Cancel buttons. After VBA displays the message box, it waits for
the user to make a decision. When the user clicks one of the three buttons,
VBA stores the choice in the 
Result
variable. Wow, that’s a lot for one piece
of text to do!
The pseudo-code says that the code needs to detect which button the user
pressed. You can use another message box to display the information like this:
MsgBox Result
This is the same technique that I use in Chapter 1. The only difference is that
the information contained in 
Result
relies on a user selection. You don’t
know in advance which button the user will select, but this code works no
matter which button the user clicks.
The final piece of pseudo-code says that VBA should end the program. You do
this with the 
End Sub
statement shown in Figure 2-1. Whenever VBA runs
out of instructions to process, it ends the program. Figure 2-2 shows what
your code should look like now. Make sure that you save the code at this
point by using the File

Save command.
Figure 2-2:
Writing
code is easy
when you
use pseudo-
code to
describe
it first.
37

Download 8,82 Mb.

Do'stlaringiz bilan baham:
1   ...   40   41   42   43   44   45   46   47   ...   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