我有以下运行良好的代码。在代码的最后一部分,对于 I=0,我试图添加仅显示重复值的代码。我有几个做不同事情的列表框。我什至有一个列出唯一值但我无法弄清楚让 listbox8 只显示 dplicate 值。
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
If GoLstBox.Items.Count <> 20 Then
MessageBox.Show("Exactly Twenty Numbers Must Be Entered")
Else
Dim goArray(GoLstBox.Items.Count - 1) As Object
GoLstBox.Items.CopyTo(goArray, 0)
Array.Sort(goArray)
ListBox6.Items.AddRange(goArray)
Array.Reverse(goArray)
ListBox5.Items.AddRange(goArray)
Dim distinctNums = goArray.Distinct()
Array.Sort(goArray)
For Each num In distinctNums
ListBox7.Items.Add(num.ToString())
'For i = 0 To goArray.Count - 2
'If goArray(i) = goArray(i + 1) Then
' ListBox8.Items(i + 1) = DirectCast(ListBox4.Items(i + 1), String))
Next
End If
End Sub