Iaintnofool 0 Newbie Poster

Hi I'm stuck on a project using VB 2005 express edition. I'm having trouble reading in data into my code from a Text File.
I'm using an openFileDialog so the user can select a file to open. The opened file will contain 3 columns and an unknown number of rows. I want to read the data from the file calling the first colum x, second y, and third z. I then want to plot a graph of the raw data (x,y). Before performing simple mathematical equations on each row of x,y and z and sum the answers.
Unfortunately so far I can't get past inputing the data into the program, so I'd be very grateful for any help you can give me.

Public Class Form1
    Dim data(i, 2) As String
    Dim g, filename As String
    Dim i, numlines, lines, As Integer
    Dim x(i), y(i), s(i) As Double
 Private Sub OpenFileBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenFileBtn.Click
        If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then                                       'opens file of users choice if cancel not pressed 
            FileOpen(1, OpenFileDialog1.FileName, OpenMode.Input)
            lines = getNumLines(1)
            FileClose(1)
            FileOpen(1, OpenFileDialog1.FileName, OpenMode.Input)
            ReDim data(lines, 2)
 For i = 0 To i = lines - 1
            Input(1, data(i, 0))
            Input(1, data(i, 1))
            Input(1, data(i, 2))
            x(i) = Val(data(i, 0))
            y(i) = Val(data(i, 1))
            s(i) = Val(data(i, 2))
            Graph1.Plotxy(x(i), y(i))
        Next i
FileClose(1)
        End If
    End Sub 
Public Function getNumLines(ByVal fileName As Integer) As Integer
        Dim numLines As Integer
        numLines = 0
        While Not (EOF(1))
            numLines = numLines + 1      'counts number of rows in the file
            Input(1, g)
        End While
        Return numLines     'return the number of lines found
    End Function
End Class
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.