Word Document Properties


Chapter 4: Storing and Modifying Information



Download 8,82 Mb.
Pdf ko'rish
bet97/207
Sana16.03.2022
Hajmi8,82 Mb.
#496217
1   ...   93   94   95   96   97   98   99   100   ...   207
Bog'liq
VBA For Dummies 5th Ed.pdf ( PDFDrive )

Chapter 4: Storing and Modifying Information
09_046500 ch04.qxp 12/5/06 5:54 PM Page 101


Listing 4-13
Keeping Track of the Time
Public Sub ShowTime()
‘ Create a time variable.
Dim MyTime As Date
‘ Obtain the current time.
MyTime = Time
‘ Display the hours, minutes, and seconds.
MsgBox “The current time is: “ + _
vbCrLf + “Hours: “ + CStr(Hour(MyTime)) + _
vbCrLf + “Minutes: “ + CStr(Minute(MyTime)) + _
vbCrLf + “Seconds: “ + CStr(Second(MyTime)), _
vbOKOnly, _
“Current Time”
End Sub
VBA provides access to the whole time value by using the 
Time
function. 
You can also use the 
Hour

Minute
, and 
Second
functions for specific infor-
mation. Not shown in the example is how you can set the current time by
using 
Time
on a line by itself and supplying a time value such as 
Time =
#1:0:0#
(for 1 a.m.). In this case, 
Time
acts as a property rather than as a
statement and accepts input in any valid format, such as 
#1 PM#
for 1 p.m.
(or 1300 military time). Notice that time and date values always appear
within the 
#
symbol rather than with the double quotes used for strings.
Using dates is similar to using time in a program. Listing 4-14 demonstrates
that you can use the 
Date
function directly instead of placing the information
in a variable. The listing also shows how to set the date (provided that you
have sufficient security rights on the workstation that you use).
Listing 4-14
Displaying Date Values
Public Sub ShowDate()
‘ Create a date variable.
Dim MyDate As Date
‘ Obtain the current date.
MyDate = Date
‘ Set the date.
Date = #1/1/1980#
‘ Display the Day, Month, and Year.
MsgBox “The current date is (DD/MM/YYYY): “ + _
CStr(Day(Date)) + “/” + _
CStr(Month(Date)) + “/” + _
CStr(Year(Date)), _
vbOKCancel, _
“Modified Date”
102

Download 8,82 Mb.

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