Hello! I am trying to load in a CSV file into DataGridView and it works but I am missing one row. I save 5 rows of data and I only get 4 in return. Here is the code(I am still trying to learn and do so by asking questions and reading about stuff):
Thanks in Advance!Code:Dim fName As String = "" OpenFileDialog1.InitialDirectory = "c:\" OpenFileDialog1.Filter = "CSV files (*.csv)|*.CSV" OpenFileDialog1.FilterIndex = 2 OpenFileDialog1.RestoreDirectory = True OpenFileDialog1.ShowDialog() fName = OpenFileDialog1.FileName Dim TextLine As String = "" If IO.File.Exists(fName) Then Dim Contents = IO.File.ReadAllLines(fName).ToList Contents.RemoveAt(0) Contents.RemoveAt(Contents.Count - 1) Contents.RemoveAt(Contents.Count - 1) For x As Integer = 0 To Contents.Count - 1 Contents(x) = Contents(x).Replace(",,,", ",").Replace(",,", ",") Contents(x) = Contents(x).Substring(0, Contents(x).Count - 1) Dim RowItem = Contents(x).Split(","c) DataGridView1.Rows.Add(RowItem) Next End If




Reply With Quote
