Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB Read Write Question

Status
Not open for further replies.
Joined
Jun 25, 2002
Messages
8
Location
US
How do you Read a file in and Write a file out in a Comma Delimited format. I realize this is probably basic stuff but I am really new to VB.

Example I have a (file named F30001x30.txt) and I want to produced the comma delimited format into a (file named F30001q30.txt)

Any help would be greatly appreciated.

 
I can get you some code but I have a question. Which file is comma deliminated? If you choose to battle wits with the witless be prepared to lose.
[machinegun][ducky]
 
The file named F30001x30.txt is the formatted file and what I want to do is Read in that file and read out file named F30001q30.txt in a comma deliminated format so that the database can take in information from the q file.
 
How is F30001x30.txt formatted? Can you give me an example. [flip] If you choose to battle wits with the witless be prepared to lose.
[machinegun][ducky]
 
Open "F30001x30.txt" For Input As #1
While Not EOF(1)
Line Input #1, sTemp
If Trim(sTemp) <> &quot;&quot; Then
arrDelimited = Split(sTemp, &quot;,&quot;)
For j = 0 To UBound(arrDelimited,1)
If arrDelimited(j) <> &quot;&quot; Then
strDelimited = strDelimited & arrDelimited(j) & vbNewLine
End If
Next
End If
Wend
Close #1

Open &quot;F30001q30.txt&quot; For Output As #1
Print #1, strDelimited
Close #1
 
Thank you foada for the help. But doesn't the code that you wrote take a comma file an output a file without commas.

Anyway I believe I get the basic understanding. I would just do it the opposite way to out put a comma file with commas formatted to where I want them to be.
 
I did not get you any code, I wanted to know the file format you were looking for. [spin] If you choose to battle wits with the witless be prepared to lose.
[machinegun][ducky]
 
Sorry Foada

I see that it was sjravee that posted the code
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top