Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Try
' Create an instance of StreamReader to read from a file.
Using sr As StreamReader = New StreamReader("mytest2.txt")
Dim line As String
Dim wnbline As Integer
Dim wnocell As Integer
' Read and display the lines from the file until the end
' of the file is reached.
Do
line = sr.ReadLine()
If line Is Nothing = False Then
If line.StartsWith("1") Then
DataGridView1.Rows.Add()
wnbline = wnbline + 1
wnocell = 1
End If
DataGridView1.Rows(wnbline - 1).Cells(wnocell -
1).Value = line.Substring(1)
wnocell = wnocell + 1
'Console.WriteLine(line)
End If
'Console.WriteLine(line)
Loop Until line Is Nothing
sr.Close()
End Using
Catch Err As Exception
' Let the user know what went wrong.
Console.WriteLine("The file could not be read:")
Console.WriteLine(Err.Message)
End Try