If と、値が 0 より大きい列を含む行を拒否する入れ子になった If があります。ここで何が欠けているのかわかりません。
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() <> -1
Dim cnt As Integer = 0
rowValue = streamReader.ReadLine()
cellValue = rowValue.Split(",")
If (cellValue(6) > 0) Then
'comparing works. need to tinnker with loop.
If (cellValue(0).ToString <> 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
私が使用している .CSV ファイルにはいくつかの列があり、最初の列は電話番号です。すべての行の電話番号を読んで、重複した電話番号に出くわしたときに、2 つの列の値を一意の行に追加したいと考えています。