Hi I am trying to count the number of duplicates in my unbound datagrid.
My problem is that when I clear my string it then starts the count a fresh count and dismisses the previous duplicate entries but if I do not clear the string I get the number of duplicates as the 2nd digit in my string this is fine but I need it do search for duplicates and display the number or duplicates of that sort in the column
I press the button.
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
DataGridView2.ColumnCount = 7
DataGridView2.Columns(0).Name = ""
DataGridView2.Columns(1).Name = ""
DataGridView2.Columns(2).Name = ""
DataGridView2.Columns(3).Name = ""
DataGridView2.Columns(4).Name = ""
DataGridView2.Columns(5).Name = ""
DataGridView2.Columns(6).Name = "UID"
Dim row As String() = New String() {"", "", "", "", "", "", "" & Label1.Text & "" & Label4.Text & " " & Label3.Text & " " & Label5.Text & " " & Label6.Text & ""}
DataGridView2.Rows.Add(row)
Timer7.Start()
End Sub
Then This
Private Sub Timer7_Tick(sender As Object, e As EventArgs) Handles Timer7.Tick
Dim date1 As String = DateTime.Now.ToString("dd MMMM yyyy")
Form3.DataGridView1.ColumnCount = 7
Form3.DataGridView1.Columns(0).Name = "SERIAL"
Form3.DataGridView1.Columns(1).Name = "PORT"
Form3.DataGridView1.Columns(2).Name = "Attempt"
Form3.DataGridView1.Columns(3).Name = "PEAK IM3"
Form3.DataGridView1.Columns(4).Name = "Date of Data"
Form3.DataGridView1.Columns(5).Name = "Time of Data"
Form3.DataGridView1.Columns(6).Name = "UID"
Dim row As String() = New String() {"" & Label1.Text & "", "" & Label4.Text & " " & Label3.Text & " " & Label5.Text & " " & Label6.Text & "", "" & Label15.Text & "", "", date1, CStr(TimeOfDay), "" & Label1.Text & "" & Label4.Text & " " & Label3.Text & " " & Label5.Text & " " & Label6.Text & ""}
Form3.DataGridView1.Rows.Add(row)
Dim dc As New Dictionary(Of String, Integer)()
Dim clV As String
For i As Integer = 0 To Form3.DataGridView1.Rows.Count - 1
If Not Form3.DataGridView1.Rows(i).IsNewRow Then
clV = Me.DataGridView2(6, i).Value.ToString()
If Not dc.ContainsKey(clV) Then
dc.Add(clV, +1)
Else
dc(clV) += 1
End If
End If
Next
Dim sb As New StringBuilder()
For Each kvp As KeyValuePair(Of String, Integer) In dc
sb.AppendLine(String.Format("{0} ", kvp.Value))
Next
Label15.Text = sb.ToString()
Timer7.Stop()
End Sub
I have spent 2 days trying to figure this out and need some advice on what to do.