Word Document Properties


Part III: Expanding Your VBA Horizons



Download 8,82 Mb.
Pdf ko'rish
bet160/207
Sana16.03.2022
Hajmi8,82 Mb.
#496217
1   ...   156   157   158   159   160   161   162   163   ...   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 190


Defining methods
Methods help you interact with an object by defining the form of interaction.
The example in this chapter has only one method, 
Show
. After you configure
a message box for use, you want to show it onscreen, so the name is appro-
priate. The 
UserForm
control also uses this name for the same purpose.
A method can rely on a 
Public Sub
if it doesn’t return a value, or a 
Public
Function
if it does. You call a method by using the same technique that you
would with a 
Sub
or 
Function
. The difference is that a method is associated
with a specific object and relies on the property values contained within that
object. This difference means that when you call a method, you don’t have
to supply every value that the method needs to perform a task — the object
supplies many (if not all) of the required arguments. Listing 8-2 contains the
Show
method code for this example.
Listing 8-2
Creating an Object Method
Public Function Show() As VbMsgBoxResult
‘ Create a variable to hold the message box result.
Dim Result As VbMsgBoxResult
‘ Create and build the option list.
Dim Options As VbMsgBoxStyle
Options = UseIcon
Options = Options Or UseButtons
Options = Options Or UseDefault
Options = Options Or UseModal
‘ Each of the Boolean values requires conversion to a
‘ style equivalent.
If UseForeground Then
Options = Options Or vbMsgBoxSetForeground
End If
If UseRightAlignment Then
Options = Options Or vbMsgBoxRight
End If
If UseRightToLeft Then
Options = Options Or vbMsgBoxRtlReading
End If
‘ The help button requires special handling.
If UseHelpButton Then
‘ Verify the user has supplied all required
‘ help information.
If TheHelpFile = “” Then
‘ If the help filename is missing, the message
‘ box can’t display help. Raise an error to
tell
(continued)
191

Download 8,82 Mb.

Do'stlaringiz bilan baham:
1   ...   156   157   158   159   160   161   162   163   ...   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