Line Count (File Qty) from Listbox Items

721 Views Asked by At

Here is the current code I am using to add files and check the number of lines in each file that was selected (file qty). This is also added into a seperate listbox for viewing.

Dim selectedItems = (From i In ListBox2.Items).ToArray()
    For Each selectedItem In selectedItems
        ListBox1.Items.Add(selectedItem)
        ListBox2.Items.Remove(selectedItem)

        Dim FileQty = selectedItem.ToString
        Dim LineCount = System.IO.File.ReadAllLines(TextBox1_Path.Text + "\" + FileQty).Length
        ListBox6.Items.Remove(LineCount)
    Next

I'm not sure how to then count all the files that were selected to obtain a grand total.

1

There are 1 best solutions below

0
On BEST ANSWER

If you do a getSelectedItems(), this will give you indexes of selected files. So with a .count on it you will have the number of selected items. Or count the number of times you did the for. This will give you the same answer.