Word Document Properties


Part II: Learning the Ropes



Download 8,82 Mb.
Pdf ko'rish
bet98/207
Sana16.03.2022
Hajmi8,82 Mb.
#496217
1   ...   94   95   96   97   98   99   100   101   ...   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 102


‘ Reset the date.
Date = MyDate
‘ Display the Day, Month, and Year.
MsgBox “The current date is (DD/MM/YYYY): “ + _
CStr(Day(MyDate)) + “/” + _
CStr(Month(MyDate)) + “/” + _
CStr(Year(MyDate)), _
vbOKCancel, _
“Actual Date”
End Sub
The code begins by creating 
MyDate
and using it to store the current date
information. The next step is to change the date by using 
Date
as a property.
As when you’re using 
Time
, you can modify 
Date
by using any valid date
format. You must have sufficient security to perform this task. If the program
fails, ask your network administrator whether you have time- and date-setting
privileges. The code creates a message box to demonstrate that the date change
actually occurred. You can verify this change by looking at the clock area of
the Taskbar Notification area.
After you click OK, the code continues by resetting the date to its original
value. Again, the code displays a message box to show that the change has
actually occurred. Notice how the code relies on the 
Day

Month
, and 
Year
functions to display both message boxes.
Working with variant data
The earlier “Understanding the numeric types” section demonstrates one 
use of the 
Variant
data type: A 
Variant
can hold any data type, including
objects. The earlier “Adding strings together with + or &” section shows
another use of the 
Variant
data type: 
Variant
variables can hold nothing
(a null value) or a string. A program can use a 
Variant
when VBA doesn’t
provide direct support for a data type (such as the 
Decimal
type); when the
type of information that the program user will provide is unknown when you
write the program; or when the native data type doesn’t support a certain
kind of storage, such as a null string. In short, a 
Variant
is the universal
data type for VBA.
VBA does track the data type of the 
Variant
variables that you create. In
Chapter 6, I demonstrate how you can see this information while debugging
the program. The data type names begin with 
Variant
and end with the
native data type. Thus, a 
Date
stored in a 
Variant
would appear as a
VariantDate
data type.
103

Download 8,82 Mb.

Do'stlaringiz bilan baham:
1   ...   94   95   96   97   98   99   100   101   ...   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