Results 1 to 2 of 2

Thread: A problam with the SHELL function..

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 1999
    Posts
    6

    Post

    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

  2. #2
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892

    Post

    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: [email protected]
    ICQ: 19552879
    AIM: RYoni69

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