Word Document Properties


Chapter 4: Storing and Modifying Information



Download 8,82 Mb.
Pdf ko'rish
bet84/207
Sana16.03.2022
Hajmi8,82 Mb.
#496217
1   ...   80   81   82   83   84   85   86   87   ...   207
Bog'liq
VBA For Dummies 5th Ed.pdf ( PDFDrive )


particu-
lar font.
87
Chapter 4: Storing and Modifying Information
09_046500 ch04.qxp 12/5/06 5:54 PM Page 87


Listing 4-3 
(continued)
‘ Tell what type of character the code displays.
MyChar = “Latin Capital Letter A with Circumflex: “
‘ Add the character.
MyChar = MyChar + Chr(&HC2)
‘Display the result.
MsgBox MyChar, vbOKOnly, “Special Character”
End Sub
This program displays a capital letter 
A
with a circumflex when you run it.
Notice how the code uses the 
Chr
function. The hexadecimal value from
Character Map appears as 
&HC2
. The 
&H
denotes a hexadecimal value, and
the 
C2
is the number of the character.
You can also get the Unicode number for a special character. A program
might use this number to ensure that the string actually contains the
requested value. The 
Asc
function converts any single character into its
numeric equivalent. Listing 4-4 shows an example of the 
Asc
function.
Listing 4-4
Getting the Numeric Value of a Character
Public Sub GetCharacter()
‘ Declare the output variables.
Dim MyChar As String
Dim CharNum As Integer
‘ Add the special character to MyChar.
MyChar = Chr(&HC2)
‘ Determine the Unicode number for the character.
CharNum = Asc(MyChar)
‘ Display the result as a decimal value.
MsgBox “Character “ + MyChar + _
“ = Decimal Value “ + CStr(CharNum), _
vbOKOnly, _
“Special Character Decimal Value”
End Sub
The program shows that the capital letter 
A
with a circumflex has a decimal
value of 194. This value equates to the hexadecimal value of 
C2h
shown in
the code. Note that when you see a lowercase 
h
follow a number, the number
is a hexadecimal value. VBA always writes hexadecimal numbers with a lead-
ing 
&H
, such as 
&HC2
. This program also includes the 
CStr
function, which
accepts an expression, such as a number, as input and outputs a string. See
the upcoming “Defining hex and octal values” section for more information
on the 
CStr
function.
88

Download 8,82 Mb.

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