dwe0608
asked on
Error Handling in Function vb.net
Hi All ... learning VB.NET as a hobby ...
How can I properly implement an error handling routine in the following function and return true for the process being started and false for an error ...
MTIA
DWE
How can I properly implement an error handling routine in the following function and return true for the process being started and false for an error ...
' pass in a fully qualified filename
Public Function fnShellOpenVB(fn As String)
Dim p As New System.Diagnostics.Process
Dim s As New System.Diagnostics.ProcessStartInfo(fn)
s.UseShellExecute = True
p.StartInfo = s
p.Start()
End Function
MTIA
DWE
ASKER
Hi Shaun,
Thanks for the fast response. So the user has some feedback on the error, would the following work?
MTIA
DWE
Thanks for the fast response. So the user has some feedback on the error, would the following work?
Public Function fnShellOpenVB(fn As String) As Boolean
Try
Dim p As New System.Diagnostics.Process
Dim s As New System.Diagnostics.ProcessStartInfo(fn)
s.UseShellExecute = True
p.StartInfo = s
p.Start()
fnShellOpenVB = True
Catch e As Exception
MsgBox(e.Message + " (" + e.ToString() + ")")
fnShellOpenVB = False
End Try
End Function
MTIA
DWE
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Shaun ... Great Answer ...
Open in new window