I'm completely new to VB.net and have been given a homework assignment. I need to be able to read certain lines and display them in a DataGridView. I have been able to link my .txt file to the DGV however it reads the whole file as opposed to the specific line. I have 3 buttons: btn1, btn2, btn3. I want each button to show the respective lines in the text file. Eventually I plan to add Column 3 up to get a total so I need each line to remain in the datagrid view once the button is pressed. After researching on-line for the past week I'm still stuck. If anyone could help me I would really appreciate it.
Text File ("products.txt")
c1 c2 c3 *<-----Coloumn Headers
one 1.50 10
two 2.50 15
three 1.50 12
Public Class Form1
Private Sub btn1_Click(sender As Object, e As EventArgs) Handles btn1.Click Dim lines = (From line In IO.File.ReadLines("products.txt") _ Select line.Split(CChar(vbTab))).ToArray For x As Integer = 0 To lines(0).GetUpperBound(0) DataGridView1.Columns.Add(lines(0)(x), lines(0)(x)) Next For x As Integer = 1 To lines.GetUpperBound(0) DataGridView1.Rows.Add(lines(x)) Next End Sub