2013-11-05 117 views
0

我想问问列表框中的项目。 我已经在列表框中分割字符串。所以如果我输入了一个file.txt,它会被分成每个单词。如何删除相同的字符串,如果有相同的字符串inlistbox

我的问题是,如果file.text中有相同的字符串,如何删除相同的字符串? 以及如何计算file.text中的每个单词(每个单词出现在file.text中的次数)?

这里是我的fullcode

 Dim s() As String = ListBox1.Items.Cast(Of String).ToArray() 

    For Each item As String In s 
     item = item.Replace(".", String.Empty) 
     item = item.Replace(Microsoft.VisualBasic.ControlChars.Quote, String.Empty) 
     item = item.Replace("(", String.Empty) 
     item = item.Replace(")", String.Empty) 
     item = item.Replace("-", String.Empty) 
     item = item.Replace(",", String.Empty) 

     ListBox2.Items.AddRange(item.Split(" "c)) 
    Next 
+0

是你的字符串的数据排序? 含义,在你将它传递给你的字符串之前,它是否被排序? –

回答

0

你为什么不使用LINQ获得项目的不同列表如下所示unique-list

这会让你获得最快的结果。

相关问题