Writing to a .txt File

D

Dan R.

Is this the proper way to write to a .txt file? Something must be out
of order b/c the status of the first x is printed next to the second x
on the out file, and the status of the second x is printed next to the
third x and so on.

Close
Open out For Output As #2
Close
Open in For Input As #1

While (EOF(1) <> True)
Input #1, x
x = Mid(x, 1, 10)

Close #2
Open out For Append As #2
Print #2, x & "|" status

' Do Stuff

Wend

Thanks,
-- Dan
 
T

Tom Ogilvy

Sub ABC()
Dim sSin As String
Dim sOut As String
Dim x As String
sSin = "C:\In.txt"
sOut = "C:\Out.txt"
Open sOut For Append As #2
Open sSin For Input As #1

i = 0
While (EOF(1) <> True)
Input #1, x
x = Mid(x, 1, 10)
i = i + 1
Status = "Status: " & i
Print #2, x & "|"; Status
Wend
Close #1
Close #2
End Sub


worked fine for me.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top