need help reading contents of a file into an array...SKYPE ME.

  • Thread starter Thread starter Cerebrus99
  • Start date Start date
C

Cerebrus99

Hi Jason,

Please post your code here, so someone can review it and let you know what
minor error exists.

Regards,

Cerebrus.
 
Could anyone spare some time and try to help me out.

I've got a .txt data file with a name, pin, balance seperated by commas. I
am opening the file and using Split to split it between the ,'s I need to
read it into an array and then check if what was entered as a name by the
user is in the array.

Can anyone be of help? Please Skype me, using the Text chat of skype. I
can transfer code just using text.....I have the code written but I dont
think I am doing something right because whenever I enter a name it is
coming back as invalid. At this point I am not even sure if I have the
array built.

Skype name: vbnethelp

Or if someone could show me how to make an array reading from a file that is
seperated by commas as above and would contain 10 records.

thank you.
 
Jason

Are you using VS 2005? If so, this is available as one of the code snippets
(under File System).

Dim filename As String = "C:\Test.txt"
Dim fields As String()
Dim delimiter As String = ","

Using parser As New TextFieldParser(filename)
parser.SetDelimiters(delimiter)

While Not parser.EndOfData
' Read in the fields for the current line
fields = parser.ReadFields()

' Add code here to use data in fields variable.
'e.g. fields(0) would be your Name field

End While
End Using

HTH

Richard
 
VS.Net 2003 that is what I have here.

Richard Bysouth said:
Jason

Are you using VS 2005? If so, this is available as one of the code
snippets
(under File System).

Dim filename As String = "C:\Test.txt"
Dim fields As String()
Dim delimiter As String = ","

Using parser As New TextFieldParser(filename)
parser.SetDelimiters(delimiter)

While Not parser.EndOfData
' Read in the fields for the current line
fields = parser.ReadFields()

' Add code here to use data in fields variable.
'e.g. fields(0) would be your Name field

End While
End Using

HTH

Richard
 
Back
Top