Hey,
I am trying to make my program open a text file, store that text file into a string array, then have a function where you can input the line number you want and extract the data from that line of the text file,
this is my code
when I run it it gives me an error saying "NullReferenceExcepion was unhandled" and that "object refernce is not set to an nstance of an object". Could some one please help me out ? Thanks.
I am trying to make my program open a text file, store that text file into a string array, then have a function where you can input the line number you want and extract the data from that line of the text file,
this is my code
VB.NET:
Dim lines As String() = IO.File.ReadAllLines(TextBox37.Text)
Public Function ValuesExtract(ByVal line_number, ByVal lines)
Dim val() As Integer = Nothing
'declare variable to store individual line
Dim values As String() = lines(line_number).Split(" ".ToCharArray, StringSplitOptions.RemoveEmptyEntries)
'extract first line of high capacitance values
val(0) = values(2)
val(1) = values(3)
val(2) = values(4)
val(3) = values(5)
'increment line number to get next 4 capacitance values
line_number = line_number + 1
values = lines(line_number).Split(" ".ToCharArray, StringSplitOptions.RemoveEmptyEntries)
val(4) = values(1)
val(5) = values(2)
val(6) = values(3)
val(7) = values(4)
'increment again for the final 4 capacitance values
line_number = line_number + 1
values = lines(line_number).Split(" ".ToCharArray, StringSplitOptions.RemoveEmptyEntries)
val(8) = values(0)
val(9) = values(1)
val(10) = values(2)
val(11) = values(3)
Return val
when I run it it gives me an error saying "NullReferenceExcepion was unhandled" and that "object refernce is not set to an nstance of an object". Could some one please help me out ? Thanks.