[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

(Drive1.Drive) CD IN ??

Posted on 2001-08-29
4
Medium Priority
?
186 Views
Last Modified: 2011-08-18
Hi i am using Dir1.Path = Drive1.Drive to pas the selcted drive to a dir1 box

the problem is when i have no CD in mu CDrom bay and this is selected my prgram falls over ??

SILKI :o)
0
Comment
Question by:silki
[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
4 Comments
 
LVL 20

Expert Comment

by:hes
ID: 6436904
0
 
LVL 28

Accepted Solution

by:
vinnyd79 earned 200 total points
ID: 6436944
why not do something like this:

On Error GoTo NMEDIA
Dir1.Path = Drive1.Drive
Exit Sub
NMEDIA:
MsgBox "No Media in Drive!"
Drive1.Drive = Left(Dir1.Path, 2)
0
 
LVL 1

Expert Comment

by:atp_expert
ID: 6440401
Option Explicit
Private Declare Function SetCurrentDirectory Lib "kernel32" Alias "SetCurrentDirectoryA" (ByVal lpPathName As String) As Long
Private Sub Command1_Click()
 Dir1.Path = IIf(SetCurrentDirectory(Left(Drive1.Drive, 2) = 0), Dir1.Path, Drive1.Drive)
End Sub

The setcurrentdirectory (api) will fail when, the directory or drive doesn't exits, so when u dont have a CD in ur drive, this api will fail, hence u can assign the previous drive.
0
 

Author Comment

by:silki
ID: 6440476
Simple yet effective !!

Thanx

SILKI
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
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…
Suggested Courses

649 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