Solved

Drive empty

Posted on 1998-06-25
2
210 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month9 days, left to enroll

615 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