Word Document Properties


Part III: Expanding Your VBA Horizons



Download 8,82 Mb.
Pdf ko'rish
bet170/207
Sana16.03.2022
Hajmi8,82 Mb.
#496217
1   ...   166   167   168   169   170   171   172   173   ...   207
Bog'liq
VBA For Dummies 5th Ed.pdf ( PDFDrive )

Part III: Expanding Your VBA Horizons 
14_046500 ch08.qxp 12/5/06 5:36 PM Page 200


‘ if there is no Help button. Raise an
error
‘ if any of these conditions is true.
Err.Raise vbObjectError + 2, _
“SpecialMsg.DefaultButton”, _
“The selected default button value is “ +
_
“incorrect. Choose a default button “ + _
“that matches the message box settings.”
Else
‘ Set the default button value.
UseDefault = vbDefaultButton3
End If
Case Button_4
If Not UseHelpButton Then
‘ Can’t have four buttons if there is no
‘ Help button, so raise an error.
Err.Raise vbObjectError + 2, _
“SpecialMsg.DefaultButton”, _
“The selected default button value is “ +
_
“incorrect. Choose a default button “ + _
“that matches the message box settings.”
Else
‘ Set the default button value.
UseDefault = vbDefaultButton4
End If
End Select
End Property
The logic that you use for error handling can become quite complex. There’s
no error handling for a 
DefaultButton
value of 
Button_1
because you 
can’t create a message box with no buttons (every message box has at least
one button). Only one setting results in a message box with just one button.
When you create a message box with 
vbOKOnly
and leave out the Help
button, there’s only one button on the message box. The 
Case Button_2
clause checks for this possibility and generates an error message when you
ask for the second button as a default on a message box with only one button.
The 
Case Button_3
error-handling logic is especially complex. When you
encounter a situation where the logic becomes this complex, it pays to take the
problem apart, solve the individual pieces, and then put the pieces together. A
message box has three buttons when you request the 
vbYesNoCancel
option.
The message box also has three buttons when you request the 
vbYesNo
option and a Help button. The message box never has three buttons when
using the 
vbOKOnly
option — even adding the Help button increases the
number of buttons to only two. The code uses all these criteria to look for 
201

Download 8,82 Mb.

Do'stlaringiz bilan baham:
1   ...   166   167   168   169   170   171   172   173   ...   207




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©www.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