How i can find multiple occurence in given 开发者_Python百科string in vb.net
For e.g my string is two times : 1234567
1234567,Desction,1.32
1234555,Desction,2.30
1234556,Desction,2.30
1234557,Desction,2.30
1234567,Desction,1.32
I want to put this two rows into a Dropdown Menu which is on my Form
Its Urgent
Thanks in Advance
Lets say that what you need is to find all duplicates in a list of strings, Using a bit of linq you can try
Dim list As New List(Of String)()
list.Add("1234567,Desction,1.32")
list.Add("1234555,Desction,2.30")
list.Add("1234556,Desction,2.30")
list.Add("1234557,Desction,2.30")
list.Add("1234567,Desction,1.32")
Dim duplicates = From s In list _
Group s By sIntog _
Where g.Count() > 1 _
Select g
For Each s In duplicates
Dim duplicate As String = s.Key
Next
Then in the For Each, you can populate the DropDown Items from the strings.
Well, in that case you can try something like
Dim duplicates As New List(Of String)()
For iString As Integer = 1 To list.Count - 1
If Not duplicates.Contains(list(iString - 1)) Then
For iCompare As Integer = iString To list.Count - 1
If list(iString - 1) = list(iCompare) Then
duplicates.Add(list(iString - 1))
Exit For
End If
Next
End If
Next
精彩评论