Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ListBox's selected items - HOW-TO? - Resolved

Status
Not open for further replies.

IlyaRabyy

Programmer
Nov 9, 2010
571
US
Colleagues,
Say, you have a form with a ListBox with SelectionMode set to Multi-select, that is to provide one of the parameters for some process. The User marks one or more items in this ListBox and hits the "Go/Run/Execute" button. And the Program now has to pick the selected items, one by one, and "feed" them into the processing procedure.
In another programming language it would be something like
Code:
LOCAL lnCount As Integer, llRet As Boolean, llGoOn As Boolean
llGoOn = .T.
For lnCount = 0 To lstCriteria.ItemsCount
   If lstCriteria.Items(lnCount).Selected
      llRet = RunSomeProcess(lstCriteria.Items(1).Value)
      If !llRet
         MessageBox("Process failed")
         llGoOn = .F.
         Exit
      EndIf
   EndIf
Next lnCount
My problem is - I can't find this Selected property or some equivalent to it in VS documentation.
Could you, please, enlighten me on this matter?
TIA!

Regards,

Ilya

P.S. Resolved:

Code:
Dim loSelItems = lstExtensions.SelectedItems, lcExt As String = "", lsFilePath As String = AddBackSlash(txtSrcDir.Text.Trim()), liCnt As Int16 = 0

' Check if the User filled this entry at all
If txtSrcDir.Text.Trim() = "" Then
   MsgBox("The entry box for Search Dir cannot be blank!", MsgBoxStyle.Critical, Me.Text & ": Invalid User's entry!")
   cmdSrcDir.Focus()
   Return lnCnt
End If

For Each lcItem In loSelItems
   lcExt = lcItem.ToString()
	
   If File.Exists(lsFilePath & lcExt) Then lnCnt = lnCnt + 1

Next

Return lnCnt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top