By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,644 Members | 2,105 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,644 IT Pros & Developers. It's quick & easy.

Checking the presence of a disc in the drive

vdraceil
100+
P: 236
Hi friends,i just wanna know whether the presence of a disc in the drive can be detected by coding in vb6.0..if the disc is present i want to perform a set of actions, else i want to display 'insert disc please'..Experts kindly help
Dec 16 '07 #1
Share this Question
Share on Google+
2 Replies


daniel aristidou
100+
P: 491
Hi friends,i just wanna know whether the presence of a disc in the drive can be detected by coding in vb6.0..if the disc is present i want to perform a set of actions, else i want to display 'insert disc please'..Experts kindly help
Hi ... sorry it took a long time but here is the code i belive will work.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2. Dim Drive As String
  3. Drive = "D:\"
  4. Dim Rename As String
  5. Rename = FileSystem.Dir(Drive, vbVolume)
  6.  
  7. If Len(Rename) = 0 Then
  8.     If MsgBox("There is no Disk Present", vbCritical + vbRetryCancel) = vbRetry Then
  9.         Command1_Click
  10.     End If
  11. Else
  12. MsgBox (Rename & " Is in the Drive")
  13. End If
  14.  
  15. End Sub
Jan 4 '08 #2

Expert 5K+
P: 8,434
There's another alternative. Add a reference to Microsoft Scripting Runtime to your project. And add a command button, of course. Then try this...

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2.   Dim fso As New FileSystemObject
  3.   Dim drv As Drive
  4.   For Each drv In fso.Drives
  5.       Me.Print drv.DriveLetter, drv.DriveType, drv.IsReady
  6.     End With
  7.   Next
  8. End Sub
Jan 4 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.