Word Document Properties


Chapter 9: Working with Arrays and Collections



Download 8,82 Mb.
Pdf ko'rish
bet175/207
Sana16.03.2022
Hajmi8,82 Mb.
#496217
1   ...   171   172   173   174   175   176   177   178   ...   207
Bog'liq
VBA For Dummies 5th Ed.pdf ( PDFDrive )

Chapter 9: Working with Arrays and Collections
15_046500 ch09.qxp 12/5/06 5:36 PM Page 207


This example shows how to use a 
For Each...Next
statement to access
each array element in turn. Notice that you don’t need to use an index in this
situation because the 
For Each...Next
statement keeps track of it for you.
The 
IndividualString
variable is a 
Variant
— the only acceptable type
when using a 
For Each...Next
statement. You don’t have to convert
IndividualString
when you add it to 
Output
because VBA tracks it as a
Variant/String
. Check out this statement in the Debugger, and you can
see how it works.
The final statement displays a message box containing the value of 
Output
.
This message box presents the list of the strings originally added to the
array. Notice that the output is a single string that the code created from the
individual array elements.
Understanding the array types
You can classify arrays in several ways. The first method is by the kind of
data that the array holds. A 
String
array is different from an 
Integer
array.
An array always keeps the array data type unique. Using a 
Variant
data type
lets you mix data types within an array. You should use this technique care-
fully because it can lead to bugs that are difficult to debug.
A second method is to define the number of array dimensions. A 
dimension
is
the number of directions in which the array holds information. A simple list,
such as the one in the earlier “Understanding array usage” section, is a
single-dimensional array. A table that consists of rows and columns is a two-
dimensional array. You can create arrays with any number of dimensions.
Listing 9-2 shows an example of a two-dimensional array that holds the result
of a calculation. Note that this is the first example to mix forms into the pro-
gram, and it also shows how to use the 
ReDim
statement. (You can find the
source code for this example on the Dummies.com site at 
http://www.
dummies.com/go/vbafd5e
.)

Download 8,82 Mb.

Do'stlaringiz bilan baham:
1   ...   171   172   173   174   175   176   177   178   ...   207




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©www.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