Word Document Properties


Part II: Learning the Ropes



Download 8,82 Mb.
Pdf ko'rish
bet89/207
Sana16.03.2022
Hajmi8,82 Mb.
#496217
1   ...   85   86   87   88   89   90   91   92   ...   207
Bog'liq
VBA For Dummies 5th Ed.pdf ( PDFDrive )

Part II: Learning the Ropes 
09_046500 ch04.qxp 12/5/06 5:54 PM Page 92


Computers also determine a numeric type based on the amount of memory
that the data requires. VBA supports three integer types, including 
Byte
(1
byte of storage), 
Integer
(2 bytes of storage), and 
Long
(4 bytes of storage).
The extra memory stores larger numbers: 0 to 255 for 
Byte
; –32,768 to 32,767
for 
Integer
; and –2,147,483,648 to 2,147,483,647 for 
Long
. See the Data Type
Summary help topic for additional details. Listing 4-7 is an example that demon-
strates various data types.
Listing 4-7
Demonstrating the Differences in Data Type Ranges
Public Sub DataRange()
‘ Declare the numeric variables.
Dim MyInt As Integer
Dim MySgl As Single
Dim MyDbl As Double
Dim MyCur As Currency
Dim MyDec As Variant
‘ Define values for each variable.
MyInt = 30 + 0.00010001000111
MySgl = 30 + 0.00010001000111
MyDbl = 30 + 0.00010001000111
MyCur = 30 + 0.00010001000111
MyDec = CDec(30 + 0.00010001000111)
‘ Display the actual content.
MsgBox “Integer:” + TwoTab + CStr(MyInt) + _
vbCrLf + “Single:” + TwoTab + CStr(MySgl) + _
vbCrLf + “Double:” + TwoTab + CStr(MyDbl) + _
vbCrLf + “Currency:” + vbTab + CStr(MyCur) + _
vbCrLf + “Decimal:” + TwoTab + CStr(MyDec), _
vbOKOnly, _
“VBA Data Types”
End Sub
The first few variable types use standard declarations. However, notice that
you can’t declare the decimal data type directly — you must declare it as a
Variant
in VBA. See the upcoming “Working with variant data” section for
more information about the 
Variant
type. The code assigns each variable
the same value. Notice that the code must use the 
CDec
function to insert a
decimal value into the 
Variant
.
The output shown in Figure 4-3 demonstrates something interesting about
the numeric data types. Each type silently dropped any decimal data that it
couldn’t hold. This is just one of many reasons why you have to carefully
consider the numeric data type that you use.
Defining hex and octal values
Using base 10 numbers is natural. You usually don’t worry about anything
other than base 10 numbers. However, computers use base 2, or binary, 
numbers. The switch in the circuitry is either on or off — 1 or 0.
93

Download 8,82 Mb.

Do'stlaringiz bilan baham:
1   ...   85   86   87   88   89   90   91   92   ...   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