Public Class Movies
Dim a As Integer, b As Integer
Dim titles(a) As String, rating(b) As String
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ListView1.Items.Clear()
Dim names As String, rate As String
Dim listviewItem As ListViewItem
names = TextBox1.Text
rate = ComboBox1.Text
titles(a) = names
a = a + 1
rating(b) = rate
b = b + 1
Array.Sort(titles)
ReDim Preserve titles(a)
ReDim Preserve rating(b)
For Each str As String In titles
For Each str2 As String In rating
If Not IsNothing(str) Then
listviewItem = ListView1.Items.Add(str)
With listviewItem
.SubItems.Add(str2)
End With
TextBox1.Clear()
End If
Next
Next
End Sub
End Class
Whenever I click add, the Items in the first column prints twice. E.g I type in the text box Choco and choose the rating GP. This is what will happen:
Title Rating
Choco GP
Choco
I really need help with it.