Word Document Properties


Part II: Learning the Ropes



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

Part II: Learning the Ropes 
12_046500 ch07.qxp 12/5/06 5:35 PM Page 166


After the 
CheckBox
is enabled, you can click it. This time, the code calls the
cbChecked_Click
sub-procedure. The code checks the 
cbChecked.Value
property and displays the appropriate message box. Again, the control auto-
matically changes the value, so you don’t have to keep track of it.
You could easily exchange the roles of the controls in this case. There’s
no reason to avoid using the 
ToggleButton
as a yes/no indicator or the
CheckBox
as an on/off toggle. However, when you build your application,
you need to consider how the visual presentation affects you. Although the
two controls work precisely the same, the 
ToggleButton
does present as 
an on/off switch and the 
CheckBox
does present as a yes/no indicator.
Making choices with option 
buttons and frames
You never use the 
OptionButton
control alone. This control always appears
in a group. A group of 
OptionButton
controls lets you make one selection
from a list of selections. Only one 
OptionButton
control is selected at any
given time, so selecting one automatically deselects all the other buttons.
Because the 
OptionButton
controls work in a group, you have to tell VBA
which controls belong to which group, especially if a form contains more
than one group. You can create groups in one of two ways. The first technique
is to add the same string to the 
GroupName
property of each memory of the
group. The advantage of using this method is that it requires less space and
can make your program work faster. In addition, this method is transparent,
so any background image you use on the form shows through.
The second method is to place the 
OptionButton
controls in a 
Frame
con-
trol. To use this technique, you must create the 
Frame
control first and then
place the 
OptionButton
controls within the 
Frame
control. The advantage
of using this method is that it’s less error prone (the first method depends
on you typing the same string each time and not making a typo), and you
can visually see which buttons belong in the same group. Frames can also
provide special visual effects, such as a sunken control group.
Unfortunately, a group of 
OptionButton
controls still acts as individual con-
trols. You have to monitor each control separately.
One way to monitor option button groups is to create a global variable and
use the 
Click
event of each control to change it. This method provides a
slight performance boost because you don’t have to determine which
OptionButton
is selected when you want to perform a task — the status
is always known. The disadvantages of this method are that it requires
slightly more code and a little more memory, and the global variable could
167

Download 8,82 Mb.

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