|
-
Mar 22nd, 2006, 12:31 AM
#1
Thread Starter
Lively Member
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:
Private Sub Drive1_Change()
On Error GoTo EH:
EH:
If err.Number = 68 Then
GoTo DISK
End If
DISK:
MsgBox "Drive A:\ is Not Ready"
Drive1.Drive = "C:\"
Exit Sub
Dir1.Path = Drive1.Drive
End Sub
when i run the program the error occured on clicking any drive(all drives)
what i have to do?
THANKS
-
Mar 22nd, 2006, 01:24 AM
#2
Hyperactive Member
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
-
Mar 22nd, 2006, 01:36 AM
#3
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Mar 22nd, 2006, 01:40 AM
#4
Re: Traping Error number 68??
@binilmb, your msgbox will always fire even if the error is not 68.
VB Code:
Private Sub Drive1_Change()
On Error GoTo EH:
Dir1.Path = Drive1.Drive
Exit Sub
EH:
If err.Number = 68 Then
MsgBox "Drive A:\ is Not Ready"
Else
MsgBox Err.Number & " - " & Err.Description
End If
Drive1.Drive = "C:\"
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|