Word Document Properties


Part II: Learning the Ropes



Download 8,82 Mb.
Pdf ko'rish
bet81/207
Sana16.03.2022
Hajmi8,82 Mb.
#496217
1   ...   77   78   79   80   81   82   83   84   ...   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 84


In most cases it doesn’t matter whether you use the 
+
or the 
&
. The 
&
is the
traditional symbol, so you’ll see it used most often. However, it’s important to
realize that the 
+
and 
&
aren’t precisely the same, even though they normally
work the same. When in doubt, use the 
&
.
The 
+
is actually a math operation; it adds two items together. When you add
two strings, VBA concatenates them as long as there are actually two values
to add. Using the 
+
symbol can help you achieve a performance benefit, espe-
cially when you need to add many strings together. The performance benefit
occurs because VBA performs fewer checks.
The 
&
is the safer symbol and the one you should use in situations where the
+
doesn’t work. For example, when you try to add a string that contains infor-
mation to a string that doesn’t contain anything (a null string), the result is a
null string. (You must use the 
Variant
data type to create a null string; dis-
cover more about this data type in the “Working with variant data” section of
the chapter.) However, when you concatenate the two strings by using the 
&
,
the result is a string with a blank (for the null) attached.
You must also use the 
&
when you want to place text within an Excel or other
application calculation. Using 
= “Hello” + “Goodbye”
results in an error,
but using 
= “Hello” & “Goodbye”
concatenates the two strings.
Use of the 
+
assumes that the two data types are the same or that you’re adding
a string to a 
Variant
that contains a string. The 
Variant
data type can contain
anything or nothing (null). You must use 
&
to concatenate dissimilar data types,
such as a string to a number.
Sometimes you’ll use the 
&
and the 
+
together to achieve a particular result. For
example, you might experience a situation where you don’t know in advance
whether a particular variable will contain a null or a string. An address might
contain a second address line, or it might contain a null value. If you use 
&
for
all of the concatenation tasks, the output will contain a blank line. However,
using the 
+
correctly displays the data without a blank line. Listing 4-2 shows
an example of how to use 
&
and 
+
together.

Download 8,82 Mb.

Do'stlaringiz bilan baham:
1   ...   77   78   79   80   81   82   83   84   ...   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