How to output a text file and separate the data into different fields using VB 2005
5 pts.
0
Q:
How to output a text file and separate the data into different fields using VB 2005
i am new at this.

This is an example of the data (in notepad) it looks like this..

1,ABC,12/12/2008
2,DEF,13/12/2008
3,GHI,14/12/2008
4,JKL,15/12/2008

i would like to read only the first line and have each field dim as varchar.

The output should be in this form:

Field 1 = 1
Field 2 = ABC
Field 3 = 12/12/2008

Thanks for your help. It's much appreciated..
ASKED: Dec 11 2008  9:33 AM GMT
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
0
35 pts.
0
A:
 RATE THIS ANSWER
0
Click to Vote:
  •   0
  •  0
  • AddThis Social Bookmark Button
Use System.IO.StreamReader class to establish connection to a text file. And then use System.IO.StreamReader class to read from the file and store into a string. Then parse the string into 3 different variables.

'Here's how you'd get the first line
Dim FirstLine as String
Dim oFile as System.IO.File
Dim oRead as System.IO.StreamReader

oRead = oFile.OpenText("C:\MyFile.txt")
FirstLine = oRead.ReadLine()
oRead.Close()


I don't have much time right now. Check out this article for the rest.

- Max
Last Answered: Dec 14 2008  5:31 PM GMT by Max99   35 pts.
0
0
Discuss This Answer:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



0