How to output a text file and separate the data into different fields using VB 2005

5 pts.
Tags:
Comma-delimited
String manipulation
Text manipulation
VB
VB 2005
Visual Basic
Visual Basic 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..

Answer Wiki

Thanks. We'll let you know when a new response is added.

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.

<pre>’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() </pre>

I don’t have much time right now. <a href=”http://articles.techrepublic.com.com/5100-10878_11-6030362.html”>Check out this article for the rest.</a>

- Max

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following