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
Solved

Drive empty

Posted on 1998-06-25
2
196 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

828 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