PDA

Click to See Complete Forum and Search --> : ListBox & Multiple Selections


Ramin
Jan 22nd, 2000, 02:07 AM
Hello Everyone,

I need to be able to select & run 1 or more "EXE" files from a list inside my ListBox:

1- Pro. A
2- Pro. B
3- Pro. C

Right now, when I select "A" and "C", for example, it starts "C" only. Please let me know how I can fix this.

Regards.

Clunietp
Jan 22nd, 2000, 04:40 AM
Dim i As Integer

For i = 0 To List1.ListCount - 1
If List1.Selected(i) = True Then
Shell List1.List(i)
End If
Next i

Ramin
Jan 22nd, 2000, 06:07 AM
Thank You for your time & reply.

It works now and as new VB user I am happy. But please read the following code and see if there is a better way:

Private Sub Button2_Click()
Dim i As Integer

List1.List(0) = "notepad.exe"
List1.List(1) = "calc.exe"
List1.List(2) = "mspaint.exe"
List1.List(3) = "C:\Program Files\Adobe\Acrobat 4.0\Reader\AcroRd32.exe"
List1.List(4) = "C:\Program Files\Microsoft Money\System\MSMONEY.EXE"
List1.List(5) = "C:\Program Files\Copernic 2000 Plus\Copernic.exe"
List1.List(6) = "C:\Lotus\Notes\notes.exe"
List1.List(7) = "C:\Program Files\WinZip\WINZIP32.EXE"
List1.List(8) = "C:\Program Files\QuickTime\QuickTimePlayer.exe"
List1.List(9) = "C:\Program Files\Aventail\Connect\as32.exe"
List1.List(10) = "C:\Program Files\CRT\CRT.EXE"
List1.List(11) = "C:\Program Files\Rhino Software\FTP Voyager\FTPVoyager.exe"
List1.List(12) = "C:\Program Files\ActiveSkin\SkinBuilder.exe"

For i = 0 To List1.ListCount - 1

If List1.Selected(i) = True Then

Shell List1.List(i)

End If

Next i

.
.
.

Now, on my VB app menu, it is supposed to show a "list" of available applications that can be installed and not the "path". As a result, obviousley after selecting and running any of them, the "ListBox" changes the "name" of the apps with their "paths"!

FYI, please note that each one of these apps should wait until the last one is installed and ended. Of course, I have already found a way of doing this part. :-)

Regards.

Aaron Young
Jan 22nd, 2000, 07:14 AM
Store the Application Paths in an Array and use the ListIndex Property of the Listbox to Reference the List and Extract the Correct EXE Name/Path, this way the Actual List Item can contain any Text you wish. I would also use an external file to build the list of files, this way you can add/delete files without having to rebuild your application, ie.

In a Flat File, "Apps.lst"..

Notepad
notepad.exe
Calculator
calc.exe
MS Paint
mspaint.exe
Adobe Acrobat 4
C:\Program Files\Adobe\Acrobat 4.0\Reader\AcroRd32.exe
MS Money
C:\Program Files\Microsoft Money\System\MSMONEY.EXE
Copernic 2000
C:\Program Files\Copernic 2000 Plus\Copernic.exe
Lotus Notes
C:\Lotus\Notes\notes.exe
WinZip
C:\Program Files\WinZip\WINZIP32.EXE
Quick Time
C:\Program Files\QuickTime\QuickTimePlayer.exe
Aventail
C:\Program Files\Aventail\Connect\as32.exe
CRT
C:\Program Files\CRT\CRT.EXE
FTP Voyager
C:\Program Files\Rhino Software\FTP Voyager\FTPVoyager.exe
Skin Builder
C:\Program Files\ActiveSkin\SkinBuilder.exe

Application Code

Dim aApps() As String

Private Sub Form_Load()
Dim iFile As Integer
Dim iApp As Integer
Dim sData As String
Dim vSplit As Variant

iFile = FreeFile
Open "C:\Files\Apps.lst" For Input As iFile
sData = Input(LOF(iFile), iFile)
Close iFile
vSplit = Split(sData, vbCrLf)
ReDim Preserve aApps(UBound(vSplit) / 2)
For iApp = 0 To UBound(vSplit) Step 2
List1.AddItem vSplit(iApp)
aApps(iApp / 2) = vSplit(iApp + 1)
Next
End Sub

Private Sub List1_DblClick()
Shell aApps(List1.ListIndex), vbNormalFocus
End Sub


------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
ajyoung@pressenter.com

Ramin
Jan 22nd, 2000, 07:28 AM
Thank you very much Aaron. I really appreciate your help.

Regards.