我正在尝试将多个数组放入单个列表框中。下面是代码。当我让每个输出进入它自己的列表框时效果很好,但我试图将它们全部放在一个带有当前标题的列表框中。有人可以帮忙吗?最后一件事,我还希望将重复值放入另一列,但不知道如何。我所能做的就是消除重复项(想超越并显示消除了哪些数字)
Public Class Form1
Dim randomNum As New Random()
Dim SampleArray(19) As Integer
Dim aryNums() As Integer = SampleArray
Dim distinctNums = SampleArray.Distinct()
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
ListBox1.Items.Clear()
ListBox2.Items.Clear()
ListBox3.Items.Clear()
For i = 0 To 19
SampleArray(i) = randomNum.Next(10, 100)
ListBox1.Items.Add(SampleArray(i).ToString)
Next
Array.Sort(SampleArray)
For i = 0 To SampleArray.GetUpperBound(0)
ListBox2.Items.Add(SampleArray(i))
Next
For Each num In distinctNums
ListBox3.Items.Add(num.ToString())
Next
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
ListBox4.Items.Add("Index" & vbTab & "Random" & vbTab & "Sorted" & vbTab & "Unique")
For i = 0 To 19
SampleArray(i) = randomNum.Next(10, 100)
ListBox4.Items.Add(i & vbTab & SampleArray(i).ToString)
'ListBox4.Items.Add(SampleArray(i).ToString)
Next
Array.Sort(SampleArray)
For i = 0 To SampleArray.GetUpperBound(0)
ListBox4.Items.Add(vbTab & vbTab & SampleArray(i))
Next
For Each num In distinctNums
ListBox4.Items.Add(vbTab & vbTab & vbTab & num.ToString())
Next
End Sub
End Class