Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Jul 2004
    Posts
    201
    Thanks
    8
    Thanked 1 Time in 1 Post

    VB: launch an app, cant get it to work, but it should do

    Ok guys i have a file list box that is set to show the files of a certain folder. I wwant to have it so that when an item is selected in the box, it executes the file and it runs. I have this so far, but keep getting errors.

    Private Sub File1_Click()
    openselected
    End Sub

    Public Sub openselected()
    SelectedFilePath = File1.Path
    SelectedFileName = File1.FileName
    Shell SelectedFilePath & "\" & SelectedFileName
    End Sub

    Iv also used this line

    Shell (SelectedFilePath & "\" & SelectedFileName)

    and

    Shell ("SelectedFilePath & "\" & SelectedFileName")

    Why isnt this working and also is it possible that whateva is show in the box, that the file extention can be take off it.

    Thanks for your time.

  • #2
    Regular Coder
    Join Date
    Jul 2004
    Posts
    201
    Thanks
    8
    Thanked 1 Time in 1 Post
    Can anyone tell me why this aint working?

  • #3
    Super Moderator
    Join Date
    May 2002
    Posts
    1,041
    Thanks
    0
    Thanked 12 Times in 12 Posts
    Try using:

    Shell SelectedFilePath + "\" + SelectedFileName

    HTH,

    -sage-
    HTML & CSS Forum Moderator

    "If you don't know what you think you know, then what do you know."
    R.I.P. Derrick Thomas #58
    1/1/1967 - 2/8/2000

  • #4
    Regular Coder
    Join Date
    Oct 2004
    Location
    In front of this computer. (Where else?)
    Posts
    442
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try this

    dim progpath as string
    progpath = SelectedFilePath & "\" & SelectedFileName & ".exe"

    Shell(progpath)

    You can first display progpath's contents to examine the string. The problem might be in the variables themselves.
    Tomorrow is the first day of the rest of your life... What have you done today?
    Tutorials
    Web: w3schools, htmldog General tips: Hardware, Networking

  • #5
    Regular Coder
    Join Date
    Jul 2004
    Posts
    201
    Thanks
    8
    Thanked 1 Time in 1 Post
    Thank you both for your reply, but sage45, your one give me the same error I was already having, "invalid procedure or argument" then u click debug and it goes to the shell line.

    and tboss your method said file not found

    Any other methods?

    Quote Originally Posted by tboss132
    You can first display progpath's contents to examine the string. The problem might be in the variables themselves.
    I already done that with my method in my first post above, I used a msgbox and it showed the correct link, it just wonr run it

  • #6
    Regular Coder
    Join Date
    Oct 2004
    Location
    In front of this computer. (Where else?)
    Posts
    442
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Compile your code. Copy your code's executable into the same directory of the executable you're trying to launch. Use relative file names.
    Tomorrow is the first day of the rest of your life... What have you done today?
    Tutorials
    Web: w3schools, htmldog General tips: Hardware, Networking


  •  

    Posting Permissions

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