Solved

Drive empty

Posted on 1998-06-25
2
192 Views
Last Modified: 2010-05-03
I want to check my CD ROM drive is EMPTY or not
if EMPTY prompt error !
0
Comment
Question by:hateli
2 Comments
 
LVL 2

Accepted Solution

by:
swilt earned 10 total points
ID: 1464268
Try this bit of code

Option Explicit

Private Sub Form_Load()
    Dim x As Integer
   
    x = nCheckDrive("e:")
    If x = 0 Then
        MsgBox "Disk in drive"
    Else
        MsgBox "No Disk in drive"
    End If
End Sub

Private Function nCheckDrive(ByVal sDrive As String) As Integer
    On Error GoTo EHDrive
   
    Dim nErrNum As Integer
   
    nErrNum = 0
    Dir$ sDrive
    nCheckDrive = nErrNum
    Exit Function
   
EHDrive:
    nErrNum = Err.Number
   ' MsgBox Err.Description
    Resume Next
End Function

0
 
LVL 6

Expert Comment

by:clifABB
ID: 1464269
swilt:
An excellent solution.  Without even using the API!
My hats off to you.
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question