Word Document Properties


Chapter 7: Interacting with the User



Download 8,82 Mb.
Pdf ko'rish
bet143/207
Sana16.03.2022
Hajmi8,82 Mb.
#496217
1   ...   139   140   141   142   143   144   145   146   ...   207
Bog'liq
VBA For Dummies 5th Ed.pdf ( PDFDrive )

Chapter 7: Interacting with the User
12_046500 ch07.qxp 12/5/06 5:35 PM Page 165


Both controls use the 
Click
event to indicate a change in status. In addition,
both controls use the 
Value
property to show their status (checked or tog-
gled). Each control maintains its status information automatically — you
don’t have to do anything special. This feature is useful when you’re creating
various types of toggled setups in addition to the more mundane task of pro-
viding input to a form.
The example in this section displays a message box each time you click the
check box or toggle button. Listing 7-3 shows the code that you need to
create this example. (You can find the source code for this example on the
Dummies.com site at 
http://www.dummies.com/go/vbafd5e
.)
Listing 7-3
Using Check Boxes
Private Sub cbChecked_Click()
‘ Verify the checked status.
If cbChecked.Value Then
‘ Display a message.
MsgBox “CheckBox Checked”
Else
‘ Display a message.
MsgBox “Checkbox Cleared”
End If
End Sub
Private Sub tbCBEnable_Click()
‘ Check the state of cbChecked.
If tbCBEnable.Value Then
‘ Disable cbChecked.
cbChecked.Enabled = True
‘ Change the caption.
tbCBEnable.Caption = “CheckBox Enabled”
Else
‘ Enable cdChecked.
cbChecked.Enabled = False
‘ Change the caption.
tbCBEnable.Caption = “CheckBox Disabled”
End If
End Sub
When the program starts, 
cbChecked
is disabled and 
tbCBEnable
is in 
the non-depressed state. Click the CheckBox Disabled button, and the code 
calls 
tbCBEnable_Click
. This sub-procedure checks the status of the
tbCBEnable.Value
property to determine which course of action to take.
In both cases, it changes the state of 
cbChecked
by using the 
Enabled
prop-
erty and the 
ToggleButton Caption
property. The code doesn’t need to
consider the 
Value
property because the control changes it automatically.
166

Download 8,82 Mb.

Do'stlaringiz bilan baham:
1   ...   139   140   141   142   143   144   145   146   ...   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