Friday, 27 September 2013

putting multiple arrays into one single Liastbox

putting multiple arrays into one single Liastbox

I am trying to put multi arrays into a single listbox. Below is the code.
It works well when I make every output go into its own listBox but I am
trying to but them all in one listbox with the current headings. Can
someone help? One last thing, I would also like the duplicate values to go
into another column but don't know how. All I can due is just eliminate
the duplicates (want to go above and beyond and show what numbers were
eliminated)
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

No comments:

Post a Comment