Results 1 to 4 of 4

Thread: Traping Error number 68??

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2005
    Posts
    112

    Question Traping Error number 68??

    hi
    i have a drivelistbox ,dirlistbox and filelistbox
    i want to trap error( Device unavailable "68")
    i placed the following code

    VB Code:
    1. Private Sub Drive1_Change()
    2.   On Error GoTo EH:
    3. EH:
    4. If err.Number = 68 Then
    5.     GoTo DISK
    6.      End If
    7.  DISK:
    8.    MsgBox "Drive A:\ is Not Ready"
    9.     Drive1.Drive = "C:\"
    10.      Exit Sub
    11.  Dir1.Path = Drive1.Drive
    12.    End Sub
    when i run the program the error occured on clicking any drive(all drives)
    what i have to do?
    THANKS

  2. #2
    Hyperactive Member binilmb's Avatar
    Join Date
    Nov 2005
    Location
    Kochi
    Posts
    472

    Re: Traping Error number 68??

    Try This


    Private Sub Drive1_Change()
    On Error GoTo EH:
    Dir1.Path = Drive1.Drive
    Exit Sub
    EH:
    If err.Number = 68 Then
    GoTo DISK
    End If
    DISK:
    MsgBox "Drive A:\ is Not Ready"
    Drive1.Drive = "C:\"
    End Sub
    ßįňįl

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Traping Error number 68??

    @Nida, That wont work as if you hit an error that is not 68 or no error at all it will still fall through and run the DISK subroutine because there is no Else condition or exit sub condition before the msgbox code.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Traping Error number 68??

    @binilmb, your msgbox will always fire even if the error is not 68.

    VB Code:
    1. Private Sub Drive1_Change()
    2. On Error GoTo EH:
    3.  
    4. Dir1.Path = Drive1.Drive
    5. Exit Sub
    6.  
    7. EH:
    8. If err.Number = 68 Then
    9.     MsgBox "Drive A:\ is Not Ready"
    10. Else
    11.     MsgBox Err.Number & " - " & Err.Description
    12. End If
    13. Drive1.Drive = "C:\"
    14.  
    15. End Sub
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width