Word Document Properties


Part II: Learning the Ropes



Download 8,82 Mb.
Pdf ko'rish
bet85/207
Sana16.03.2022
Hajmi8,82 Mb.
#496217
1   ...   81   82   83   84   85   86   87   88   ...   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 88


Removing excess space
Some strings come with extra baggage in the form of spaces that you don’t
need. The spaces can appear at either end of the string or at both ends. VBA
provides three essential functions for removing excess space:
LTrim
:
Removes the excess spaces from the left side of the string
RTrim
:
Removes the excess spaces from the right side of the string
Trim
:
Removes excess spaces from both ends of the string
You can combine these three functions with other string functions to pro-
duce specific information. Listing 4-5 shows the 
LTrim

RTrim
, and 
Trim
functions in action. It also demonstrates how to combine these three func-
tions with other functions to produce new information.
Listing 4-5
Removing Spaces from a String
Public Sub RemoveSpace()
‘ Declare a string with spaces.
Dim IStr As String
‘ Declare an output string.
Dim Output As String
‘ Add a string to IStr
IStr = “ Hello “
‘ Show the original string length.
Output = “Original String Length: “ + CStr(Len(IStr))
‘ Get rid of the spaces on the left.
Output = Output + vbCrLf + _
“LTrim Length: “ + CStr(Len(LTrim(IStr))) + _
“ Value: “ + Chr(&H22) + LTrim(IStr) +
Chr(&H22)
‘ Get rid of the spaces on the right.
Output = Output + vbCrLf + _
“RTrim Length: “ + CStr(Len(RTrim(IStr))) + _
“ Value: “ + Chr(&H22) + RTrim(IStr) +
Chr(&H22)
‘ Get rid of all the extra spaces.
Output = Output + vbCrLf + _
“Trim Length: “ + CStr(Len(Trim(IStr))) + _
“ Value: “ + Chr(&H22) + Trim(IStr) +
Chr(&H22)
‘ Display the result.
MsgBox Output, vbOKOnly, “Trimming Extra Spaces”
End Sub
89

Download 8,82 Mb.

Do'stlaringiz bilan baham:
1   ...   81   82   83   84   85   86   87   88   ...   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