Drive List Box Help Please for Error 68

Thread Solved

Join Date: Jul 2006
Posts: 19
Reputation: jasper54321 is an unknown quantity at this point 
Solved Threads: 0
jasper54321 jasper54321 is offline Offline
Newbie Poster

Drive List Box Help Please for Error 68

 
0
  #1
Aug 18th, 2006
Hi to whoever is ready my post and call for help. I am an absolute novice at VB6 and are trying hard to learn this program off my own back from the internet and an old tutorial book i got my hands on. So far ive managed to build a database program, but i am stuck with one bug that is getting on me nerves because i cannot find a fix for it.
The drive list box gives an error message when drive not found. Error 68.
Is there a simple fix to display a message box and have the drive list box return to default after exiting the message box.
It makes my program crash every time no drive is found.

Ive tried for over aweek to suss it any help is much appreciated.

Here is part of my code for my program, a snapshot of the form i need it for is here http://www.andoverhydroponics.co.uk/vb6databasehelp.htm


Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1.  
  2. Option Explicit
  3. Private Declare Function ShellExecute Lib "shell32.dll" Alias _
  4. "ShellExecuteA" (ByVal hWnd As Long, ByVal lpszOp As _
  5. String, ByVal lpszFile As String, ByVal lpszParams As String, _
  6. ByVal lpszDir As String, ByVal FsShowCmd As Long) As Long
  7. Private Declare Function GetDesktopWindow Lib "user32" () As Long
  8. Const SW_SHOWNORMAL = 1
  9. Const SE_ERR_FNF = 2&
  10. Const SE_ERR_PNF = 3&
  11. Const SE_ERR_ACCESSDENIED = 5&
  12. Const SE_ERR_OOM = 8&
  13. Const SE_ERR_DLLNOTFOUND = 32&
  14. Const SE_ERR_SHARE = 26&
  15. Const SE_ERR_ASSOCINCOMPLETE = 27&
  16. Const SE_ERR_DDETIMEOUT = 28&
  17. Const SE_ERR_DDEFAIL = 29&
  18. Const SE_ERR_DDEBUSY = 30&
  19. Const SE_ERR_NOASSOC = 31&
  20. Const ERROR_BAD_FORMAT = 11&
  21. Function OpenDocument(ByVal DocName As String) As Long
  22. Dim Scr_hDC As Long
  23. 'Scr_hDC = GetDesktopWindow()
  24. OpenDocument = ShellExecute(Me.hWnd, "Open", DocName, _
  25. "", "C:\", SW_SHOWNORMAL)
  26. End Function
  27. Private Sub cmdExit_Click()
  28. Unload Me
  29. End Sub
  30. Private Sub Dir1_Change()
  31. File1.Path = Dir1.Path
  32. End Sub
  33. Private Sub Drive1_Change()
  34. Dir1.Path = Drive1.Drive
  35. End Sub
  36.  
  37. Private Sub File1_DblClick()
  38. Dim r As Long, msg As String
  39. Dim str As String
  40. If Right(Dir1.Path, 1) = "\" Then
  41. str = Dir1.Path & File1.FileName
  42. Else
  43. str = Dir1.Path & "\" & File1.FileName
  44. End If
  45. Me.Caption = str
  46. r = OpenDocument(str)
  47. 'If there is an error, the return value is
  48. 'less than or equal to 32
  49. If r <= 32 Then
  50. Select Case r
  51. Case SE_ERR_FNF
  52. msg = "File not found"
  53. Case SE_ERR_PNF
  54. msg = "Path not found"
  55. Case SE_ERR_ACCESSDENIED
  56. msg = "Access denied"
  57. Case SE_ERR_OOM
  58. msg = "Out of memory"
  59. Case SE_ERR_DLLNOTFOUND
  60. msg = "DLL not found"
  61. Case SE_ERR_SHARE
  62. msg = "A sharing violation occurred"
  63. Case SE_ERR_ASSOCINCOMPLETE
  64. msg = "Incomplete or invalid file association"
  65. Case SE_ERR_DDETIMEOUT
  66. msg = "DDE Time out"
  67. Case SE_ERR_DDEFAIL
  68. msg = "DDE transaction failed"
  69. Case SE_ERR_DDEBUSY
  70. msg = "DDE busy"
  71. Case SE_ERR_NOASSOC
  72. msg = "No association for file extension"
  73. Case ERROR_BAD_FORMAT
  74. msg = "Invalid EXE file or error in EXE image"
  75. Case Else
  76. msg = "Unknown error"
  77. End Select
  78. MsgBox msg
  79. End If
  80. End Sub

Thanks Bill
Last edited by Comatose; Aug 19th, 2006 at 11:07 pm.
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 19
Reputation: jasper54321 is an unknown quantity at this point 
Solved Threads: 0
jasper54321 jasper54321 is offline Offline
Newbie Poster

Re: Drive List Box Help Please for Error 68

 
1
  #2
Aug 19th, 2006
Thanks to everyone who took the time to read my post and look at the problem. I did mamnage to solve it in the end by adding this simple code.

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Private Sub Drive1_Change()
  2. On Error GoTo HandleErrors
  3. Dir1.Path = Drive1.Drive
  4. frmAssociation.Refresh
  5. HandleErrors:
  6. frmAssociation.Refresh
  7. ExitLine:
  8. Exit Sub
  9. End Sub
Last edited by Comatose; Aug 19th, 2006 at 11:07 pm.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Drive List Box Help Please for Error 68

 
0
  #3
Aug 19th, 2006
Thanks for following up the solution.... it's a great help for others following and having the same problem.
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 19
Reputation: jasper54321 is an unknown quantity at this point 
Solved Threads: 0
jasper54321 jasper54321 is offline Offline
Newbie Poster

Re: Drive List Box Help Please for Error 68

 
0
  #4
Aug 20th, 2006
It is what it is all about. Or what it should be all about. I appreciate any help with this. Im not good with books and prefer a practical learning meathod.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC