PDA

Click to See Complete Forum and Search --> : A problam with the SHELL function..


J0e B0b
Nov 21st, 1999, 12:18 AM
Hello, I am starting to understand the shell function, but the error from the shell is the thing I don't get.

I have this
----code----
dim path as string
path = text1.text
shell (path)
----code----

Pretty easy, I have text1 the path. The USER locates the path from a Commondialog.

But sometimes the path isn't found and an error comes up from the shell.

How do I cancle this error and continue on to a diffrent action.

An action like,
If shell(path) = false then
do action here
msgbox ("Path not found please try locating it again")

something like that.

Please help, thank you

Yonatan
Nov 21st, 1999, 12:23 AM
Try this:

On Error Resume Next
If Len(Trim(Text1.Text)) = 0 Or Len(Dir(Text1.Text)) = 0 Then
Call MsgBox("Error: " & Text1.Text & " - Path doesn't exist.", vbCritical, "Path Doesn't Exist")
Else
Call Shell(Text1.Text, vbNormalFocus)
If Err.Number <> 0 Then
Call MsgBox("Error #" & Err.Number & ": " & Err.Description, vbCritical, "Runtime Error")
End If
End If

------------------
Yonatan
Teenage Programmer
E-Mail: RZvika@netvision.net.il
ICQ: 19552879 (http://www.icq.com/19552879)
AIM: RYoni69