Word Document Properties


Chapter 6: Trapping Errors and Squashing Bugs



Download 8,82 Mb.
Pdf ko'rish
bet136/207
Sana16.03.2022
Hajmi8,82 Mb.
#496217
1   ...   132   133   134   135   136   137   138   139   ...   207
Bog'liq
VBA For Dummies 5th Ed.pdf ( PDFDrive )

Chapter 6: Trapping Errors and Squashing Bugs
11_046500 ch06.qxp 12/5/06 5:35 PM Page 153


Notice the three options in the Watch Type group. VBA assumes that you
want to create a watch expression. That’s what you get when you create a
quick watch or use the drag-and-drop method. You can also set a watch to
cause the program to break when the value is true or when it changes.
Creating a break condition is one of the more interesting ways to use the
Watches window.
154
Part II: Learning the Ropes 
11_046500 ch06.qxp 12/5/06 5:35 PM Page 154


Chapter 7
Interacting with the User
In This Chapter
Using forms to interact with the user
Creating forms by using controls
Designing forms for specific Microsoft Office applications
V
BA utility programs can usually perform their jobs without much input.
However, a VBA program that helps you perform a task usually needs
some type of input. A 
form
provides fields where you can enter or read addi-
tional information, objects (such as labels) that display information, and con-
trols (such as command buttons) that help you interact with the form.
You might need a form that asks about the machine environment or how to
interact with the data. Forms can also provide formatted output in ways that
a message box can’t. You can include fields on the form that format data and
present it in a useful manner. You use forms constantly in Windows, in the
form of dialog boxes and data entry windows.
This chapter provides an overview of VBA forms. You can also find forms in
most of the remaining chapters of this book. VBA forms can include complex
concepts, but the best forms are simple and easy to use. The examples in this
chapter concentrate on the idea of simplicity. Other chapters build on this
base and demonstrate special kinds of forms.
Understanding Forms
It’s easy to think of forms as blobs with controls attached because so many
examples of bad form design are available. Well-designed forms consider a
number of requirements, such as how the information flows from one area
to the next. A form also needs prompts that are easy to understand and a
pleasing presentation. You might think that designing such a form is hard,
but if you follow the same strategy as you do with other areas of program-
ming, you can create great forms with relative ease.
12_046500 ch07.qxp 12/5/06 5:35 PM Page 155


Using forms creatively
Good design begins when you consider how your application uses the infor-
mation that appears on the form and how you want to interact with it. A form
that presents every piece of information that you might ever need sounds
good until you try to use it. A form should contain focused information that
easily fits on any display that you use. You might find that you need to design
a series of forms that appear in sequence.
Another consideration is clutter. Even if you create a focused form, it might
contain too much nonessential information. That’s why you see Details and
Properties buttons of various kinds on forms. When you need to see the
details, you can click the button to present another form or expand the exist-
ing form. Otherwise, you can ignore the details and provide just the essentials.
Add informational forms to your program as needed. When a program com-
pletes a task, the program should tell you about it. A message box that says
“I’m done” might seem appropriate, but often it’s a nuisance. The exception
to this rule is when the user is actually waiting for confirmation that the
application has completed a task, in which case you should display the 
message box. Otherwise, you can include program statistics or other helpful
information as part of an informational field or a status bar. I often build sta-
tistical forms into my programs so that I can monitor performance. When I
see that the program isn’t performing as expected, I know that I need to look
for potential problems. I often fix the problem long before it becomes a work-
stopping issue.
The important issue to consider is that a form is an interaction between a
person and the program running on the computer. If the form that you design
doesn’t evoke a response, perhaps you haven’t used the form creatively enough.
You should be able to look at a form and have a good idea of its purpose. Each
control (such as a pushbutton) should provide a 
ToolTip
(the little window
that pops up when you hover the mouse over the control) that helps anyone
using the form to understand the intent of that control. Finally, context-
sensitive help and other forms of visual aid should make difficult forms easy
to understand.
Designing a form for your application
When you use the Forms Designer, you can easily get the idea that the VBA
Integrated Development Environment (IDE) is somehow performing magic on
your behalf by creating forms visually. A form is simply a specialized kind of
code, and you use code to perform a number of tasks in this book. Forms are
simply an extension of what you do when you perform any other task. The
only difference is that a form is visual: It presents information onscreen in a
form that the user can see.
156

Download 8,82 Mb.

Do'stlaringiz bilan baham:
1   ...   132   133   134   135   136   137   138   139   ...   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