Search code examples
vb.netvisual-studiobindingsource

Count how many rows has value in bindingsource


I have a column that has multiple rows with the same value. I want to find how many rows there is that has the search term.

My code so far

Dim foundindex As Integer
foundindex = Me.ProcessLogBindingSource.Find("HS", HSbox.Text.ToUpper)
msgbox(foundindex)

But this always returns a value of 1. I presume it stops searching once it finds the first row with the search term in. How do i get it to count how many rows has it in?

Using VB.Net in visual studio.


Solution

  • You can set a filter an then use the Count-property:

    Me.ProcessLogBindingSource.Filter = "HS = '" & HSbox.Text & "'"
    MsgBox(Me.ProcessLogBindingSource.Count)