User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Visual Basic 4 / 5 / 6 section within the Software Development category of DaniWeb, a massive community of 425,998 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,697 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums
Views: 2744 | Replies: 3 | Solved
Reply
Join Date: Jul 2006
Posts: 14
Reputation: jasper54321 is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
jasper54321 jasper54321 is offline Offline
Newbie Poster

Drive List Box Help Please for Error 68

  #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


      Option Explicit
      Private Declare Function ShellExecute Lib "shell32.dll" Alias _
      "ShellExecuteA" (ByVal hWnd As Long, ByVal lpszOp As _
      String, ByVal lpszFile As String, ByVal lpszParams As String, _
      ByVal lpszDir As String, ByVal FsShowCmd As Long) As Long
      Private Declare Function GetDesktopWindow Lib "user32" () As Long
      Const SW_SHOWNORMAL = 1
      Const SE_ERR_FNF = 2&
      Const SE_ERR_PNF = 3&
      Const SE_ERR_ACCESSDENIED = 5&
      Const SE_ERR_OOM = 8&
      Const SE_ERR_DLLNOTFOUND = 32&
      Const SE_ERR_SHARE = 26&
      Const SE_ERR_ASSOCINCOMPLETE = 27&
      Const SE_ERR_DDETIMEOUT = 28&
      Const SE_ERR_DDEFAIL = 29&
      Const SE_ERR_DDEBUSY = 30&
      Const SE_ERR_NOASSOC = 31&
      Const ERROR_BAD_FORMAT = 11&
      Function OpenDocument(ByVal DocName As String) As Long
          Dim Scr_hDC As Long
          'Scr_hDC = GetDesktopWindow()
          OpenDocument = ShellExecute(Me.hWnd, "Open", DocName, _
          "", "C:\", SW_SHOWNORMAL)
      End Function
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
    
Private Sub File1_DblClick()
Dim r As Long, msg As String
          Dim str As String
          If Right(Dir1.Path, 1) = "\" Then
              str = Dir1.Path & File1.FileName
          Else
              str = Dir1.Path & "\" & File1.FileName
          End If
          Me.Caption = str
          r = OpenDocument(str)
          'If there is an error, the return value is
          'less than or equal to 32
          If r <= 32 Then
              Select Case r
                  Case SE_ERR_FNF
                      msg = "File not found"
                  Case SE_ERR_PNF
                      msg = "Path not found"
                  Case SE_ERR_ACCESSDENIED
                      msg = "Access denied"
                  Case SE_ERR_OOM
                      msg = "Out of memory"
                  Case SE_ERR_DLLNOTFOUND
                      msg = "DLL not found"
                  Case SE_ERR_SHARE
                      msg = "A sharing violation occurred"
                  Case SE_ERR_ASSOCINCOMPLETE
                      msg = "Incomplete or invalid file association"
                  Case SE_ERR_DDETIMEOUT
                      msg = "DDE Time out"
                  Case SE_ERR_DDEFAIL
                      msg = "DDE transaction failed"
                  Case SE_ERR_DDEBUSY
                      msg = "DDE busy"
                  Case SE_ERR_NOASSOC
                      msg = "No association for file extension"
                  Case ERROR_BAD_FORMAT
                      msg = "Invalid EXE file or error in EXE image"
                  Case Else
                      msg = "Unknown error"
              End Select
              MsgBox msg
          End If
End Sub

Thanks Bill
Last edited by Comatose : Aug 19th, 2006 at 10:07 pm.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2006
Posts: 14
Reputation: jasper54321 is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
jasper54321 jasper54321 is offline Offline
Newbie Poster

Re: Drive List Box Help Please for Error 68

  #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.

Private Sub Drive1_Change()
On Error GoTo HandleErrors
Dir1.Path = Drive1.Drive
frmAssociation.Refresh
HandleErrors:
frmAssociation.Refresh
ExitLine:
Exit Sub
End Sub
Last edited by Comatose : Aug 19th, 2006 at 10:07 pm.
Reply With Quote  
Join Date: Dec 2004
Location: Lincoln Park, Michigan
Posts: 1,744
Reputation: Comatose is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 108
Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Moderator

Re: Drive List Box Help Please for Error 68

  #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  
Join Date: Jul 2006
Posts: 14
Reputation: jasper54321 is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
jasper54321 jasper54321 is offline Offline
Newbie Poster

Re: Drive List Box Help Please for Error 68

  #4  
Aug 19th, 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  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Visual Basic 4 / 5 / 6 Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum

All times are GMT -4. The time now is 12:20 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC