Word Document Properties


Part II: Learning the Ropes



Download 8,82 Mb.
Pdf ko'rish
bet125/207
Sana16.03.2022
Hajmi8,82 Mb.
#496217
1   ...   121   122   123   124   125   126   127   128   ...   207
Bog'liq
VBA For Dummies 5th Ed.pdf ( PDFDrive )

Part II: Learning the Ropes 
11_046500 ch06.qxp 12/5/06 5:35 PM Page 140


The Microsoft Scripting Runtime Library has many powerful features that I
explore in detail in other parts of this book. The feature that you use in this
section (see Listing 6-1) demonstrates how to check for disk space and
recover from an error when the disk drive doesn’t have enough space. (You
can find the source code for this example on the Dummies.com site at
http://www.dummies.com/go/vbafd5e
.)
Listing 6-1
Determining the Amount of Free Disk Space
Public Sub DriveTest()
‘ Create a variable to hold the free space.
Dim FreeSpace As Double
‘ Create a reference to the file system.
Dim MyFileSystem As FileSystemObject
‘ Create a reference for the target drive.
Dim MyDrive As Drive
‘ Create a dialog result variable.
Dim Result As VbMsgBoxResult
‘Provide a jump back point.
DoCheckAgain:
‘ Fill these two objects with data so they show the
‘ available space on drive C.
Set MyFileSystem = New FileSystemObject
Set MyDrive = MyFileSystem.GetDrive(“C”)
‘ Determine the amount of free space.
FreeSpace = MyDrive.AvailableSpace
‘ Make the check.
If FreeSpace < 1000000000 Then
‘ The drive doesn’t have enough space. Ask what to
‘ do.
Result = MsgBox(“The drive doesn’t have enough “ +
_
“space to hold the data. Do you” +
_
“ want to correct the error?” + _
vbCrLf + _
Format(FreeSpace, “###,###”) + _
“ bytes available, “ + _
“1,000,000,000 bytes needed.”, _
(continued)
141
Chapter 6: Trapping Errors and Squashing Bugs
11_046500 ch06.qxp 12/5/06 5:35 PM Page 141



Download 8,82 Mb.

Do'stlaringiz bilan baham:
1   ...   121   122   123   124   125   126   127   128   ...   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