|
-
Nov 25th, 2002, 06:31 PM
#1
Thread Starter
Lively Member
Listbox selected item help.
I have a list box that is filled with files. Now I need to be able to take the selected file and then launch a program that will use the file. I know how to launch the program, but I just dont know how to take the selected item and put it into a varible. It wont take strings... So I'm at a loss. Or maybe it will but I dont know how.
Anyway if anyone has some ideas please let me know.
12/32/84 - I need some code to make me a sandwhich.
-
Nov 25th, 2002, 06:48 PM
#2
Are you trying to get the text of the selected item? Use SelectedText.
-
Nov 25th, 2002, 07:44 PM
#3
Thread Starter
Lively Member
SeletedText wont work. Its not a member of a listbox.
I assume you ment SeletedItems?
But I did get the code below to work.. Sort of. But I need a way to pass commandline arguments to the "fceu.exe"
Code:
Shell(GetSetting("Multi-Front", "NesEmu", "EmuPath_Name"), AppWinStyle.NormalFocus)
Next I would need to add (lstRomsNes.SelectedItems) as a command line argument. Have any ideas?
Last edited by Jes|er; Nov 25th, 2002 at 10:08 PM.
12/32/84 - I need some code to make me a sandwhich.
-
Nov 25th, 2002, 10:57 PM
#4
Sorry I guess I was thinking of the ComboBox. Do you want each SelectedItem to be a seperate commandline argument or all run together? Also what are you filling the Listbox items with? Strings? Objects?
VB Code:
'if you want them all run together it'd be something like this
dim sb as New System.Text.StringBuilder()
dim o as Object
For each o in lstRomsNes.SelectedItems
Sb.Append(o.ToString & ",")
Next
If sb.Length > 1 Then sb.Remove(sb.Length - 1, 1)'trim last comma
'commandline arguments now are in
Msgbox(sb.ToString)
Or if you want them seperate then just set it while doing the for..each loop.
-
Nov 26th, 2002, 08:06 PM
#5
Thread Starter
Lively Member
Thank you! Thanks works pefectly. Now I have another problem..
The filenames are like: ADAD Corp (U).zip
So when I pass the filename to the program it says
it cant find C:\Dir\ADAD!
So I need to rename the file and then store it in a temp
dir..
Ok so its not that hard.. I got this from VS.NET Help:
Code:
Public Sub Rename(ByVal OldPath As String, _
ByVal NewPath As String)
Dim OldName, NewName As String
OldName = "test.txt"
NewName = "renamed.txt" ' Define file names.
Rename(OldName, NewName) ' Rename file.
OldName = "C:\test.txt"
NewName = "C:\renamed.txt"
Rename(OldName, NewName) ' Move and rename file.
End Sub
But now I cant figure out how to call this sub! Call Rename() gives me an error, as does just Rename() ..
Last edited by Jes|er; Nov 26th, 2002 at 08:36 PM.
12/32/84 - I need some code to make me a sandwhich.
-
Nov 26th, 2002, 08:44 PM
#6
Where are you getting the Rename function from? What error are you getting?
Its probably something like:
IO.File.Rename(OldName,NewName)
Or
File.Rename(OldName,NewName)
-
Nov 26th, 2002, 08:47 PM
#7
Wharever is rejecting the path could be expecting a ShortPathname also, which I think you can get from the FileInfo object I believe.
-
Nov 26th, 2002, 08:58 PM
#8
Thread Starter
Lively Member
IO.File.Rename(OldName,NewName) seems to work.
I also found this to work:
FileCopy("C:\test.txt", "C:\renamed.txt") which is
shorter. 
I want to thank you for all your help. You have been of tremendus assistance.
12/32/84 - I need some code to make me a sandwhich.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|