PDA

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



Anthony2oo4
02-05-2005, 12:25 AM
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. ;)

Anthony2oo4
02-09-2005, 04:27 PM
Can anyone tell me why this aint working?

sage45
02-09-2005, 05:36 PM
Try using:

Shell SelectedFilePath + "\" + SelectedFileName

HTH,

-sage-

tboss132
02-09-2005, 06:02 PM
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.

Anthony2oo4
02-11-2005, 09:48 PM
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 :confused:

Any other methods? :thumbsup:


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 :confused: ;)

tboss132
02-12-2005, 12:37 PM
Compile your code. Copy your code's executable into the same directory of the executable you're trying to launch. Use relative file names.