Note that there are some explanatory texts on larger screens.

plurals
  1. POChecking for duplicates in DataGridView
    primarykey
    data
    text
    <p>I have an If and a nested-If that rejects rows with columns that have a value greater than 0. The nested-If is supposed to check for doubles and add up the duplicate values I need but it's not. I'm not sure what I'm missing here.</p> <pre><code> Dim rowValue As String Dim cellValue As String() If System.IO.File.Exists("shortlist.csv") Then Using streamReader As System.IO.StreamReader = New StreamReader("shortlist.csv") 'Defines columns rowValue = streamReader.ReadLine() cellValue = rowValue.Split(",") With dgv.Columns .Add(cellValue(0).ToString, cellValue(0).ToString) .Add(cellValue(3).ToString, cellValue(3).ToString) .Add(cellValue(5).ToString, cellValue(5).ToString) .Add(cellValue(6).ToString, cellValue(6).ToString) .Add(cellValue(8).ToString, cellValue(8).ToString) End With ' Reading content While streamReader.Peek() &lt;&gt; -1 Dim cnt As Integer = 0 rowValue = streamReader.ReadLine() cellValue = rowValue.Split(",") If (cellValue(6) &gt; 0) Then 'comparing works. need to tinnker with loop. If (cellValue(0).ToString &lt;&gt; dgv.Rows(cnt).Cells("Phone Number").Value) Then dgv.Rows.Add(cellValue(0).ToString, cellValue(3).ToString, cellValue(5).ToString, cellValue(6).ToString, cellValue(8).ToString) Else dgv.Rows(cnt).Cells(3).Value = (cellValue(6) + Integer.Parse(dgv.Rows(cnt).Cells(3).Value)) dgv.Rows(cnt).Cells(4).Value = (cellValue(8) + Integer.Parse(dgv.Rows(cnt).Cells(4).Value)) cnt += 1 End If End If End While End Using Else MsgBox("No File is Selected") End If </code></pre> <p>The .CSV file I'm working with has several columns, the first being a phone number. As I read every rows phone number and I come across a duplicate phone number I want to add the values from two columns to their unique rows.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload