Home All Groups Group Topic Archive Search About

Error setting CSV to display text

Author
5 May 2006 6:10 PM
llively2
Object reference not set to an instance of an object. pstrfields =
psrdline.Split(pchrDelimiter)

What am I missing here?

Thanks in advance,

Lynn

Author
5 May 2006 6:25 PM
llively2
Here is the code:

Dim psrdCurrent As System.IO.StreamReader
Dim pintcount As Integer
Dim psrdline As String
Dim pstrfields() As String

Dim filename As String
filename = "C:\Documents and Settings\Me\My Documents\Visual Studio
Projects\Multicam.csv"
psrdCurrent = New System.IO.StreamReader(filename)
psrdline = psrdCurrent.ReadLine()
Do Until psrdline = Nothing
Dim psrdfile As String
psrdfile = psrdline & CrLf
psrdline = psrdCurrent.ReadLine()
Loop
Dim pchrDelimiter As Char() = {ToChar(",")}
pstrfields = psrdline.Split(pchrDelimiter)
pintcount += 1
TextBox3.Text = pstrfields(6)
psrdCurrent.Close()
Author
5 May 2006 7:23 PM
jayeldee
You're looping until psrdline is equal to Nothing then trying to access
psrdfile.

pstrfields = psrdline.Split(pchrDelimiter)
pintcount += 1
TextBox3.Text = pstrfields(6)

You may also want to put these lines inside the loop unless it was your
intention to split the entire file into one array, then set the
TextBox3.Text once.

John