Word Document Properties


Part II: Learning the Ropes



Download 8,82 Mb.
Pdf ko'rish
bet77/207
Sana16.03.2022
Hajmi8,82 Mb.
#496217
1   ...   73   74   75   76   77   78   79   80   ...   207
Bog'liq
VBA For Dummies 5th Ed.pdf ( PDFDrive )

Part II: Learning the Ropes 
08_046500 ch03.qxp 12/5/06 5:34 PM Page 78


Chapter 4
Storing and Modifying 
Information
In This Chapter
Using variables in programs
Using constants in programs
Working with various data types
Changing data by using operators
Designing a report for Excel
I
n this chapter, I refine the concept of a variable by describing variable
types and how you can modify their content. Understanding how a com-
puter stores information is very important. Computers don’t see information
the same way that you do — many methods of representing information that
seem obvious to you are invisible to the computer.
As far as the computer is concerned, everything is a series of bits that it has
to move around. Data types were invented, sometimes by trial and error, to
make the bits easier for humans to understand. For example, when you see
the letter 
C
on the display, all that the computer sees is a series of 8 bits
that form a special number. Interpretation of this number as the letter 
C
is
for your benefit. Understanding that everything is a series of bits makes this
chapter easier to understand.
When you begin to realize that you’re in control — that you decide how to
organize and interpret the bits the computer is moving around for you —
you’ve taken a large step in understanding how VBA works. VBA helps you
tell the computer how you want the bits moved around. In the following sec-
tions, I describe various ways in which you can interpret and modify the bits
that the computer stores for you.
09_046500 ch04.qxp 12/5/06 5:54 PM Page 79


Understanding Variables and Constants
VBA provides many levels of data interpretation. Some data interpretations
help you make your program reliable, others make it run faster, still others
provide accuracy, and a few make the data easier to interpret. One of the two
big distinctions is between variables and constants. You can modify a 
variable
anytime the program can actually access it. A 
constant,
however, retains the
same value all the time. You use variables as storage containers for data that
changes, and you use constants for data that doesn’t change. Variables are
more flexible than constants are, but constants make your program run
faster, so each type of storage has its place.
Making the declaration
All data in a VBA program looks like a series of bits to the computer. The
computer doesn’t understand the difference between a constant and a 
variable — VBA provides this distinction for your benefit. You use different
methods to mark variables and constants in your program.
Variables have a scope and a data type. See the “Defining the Data Types” sec-
tion, later in this chapter, for data type descriptions and how to use them. See
the “Getting the Scoop on Scope” section of Chapter 3 for scope issues. Declare
variables with both scope and data type so that VBA knows how to work with
them. Constants can also have a scope, but they don’t have a data type associ-
ated with them. A special constant type, 
#Const
, lets you define conditional
constants — those that help you tell the compiler how to compile an applica-
tion. Listing 4-1 shows some examples of variable and constant declarations.

Download 8,82 Mb.

Do'stlaringiz bilan baham:
1   ...   73   74   75   76   77   78   79   80   ...   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