Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 220
Default Writing to a .txt File

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Writing to a .txt File

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.

--
Regards,
Tom Ogilvy


"Dan R." wrote:

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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Writing to a .txt File

Hi Dan,

I suggest to "steal" code:
http://www.erlandsendata.no/english/...atextexportcsv

Regards,
Bernd

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
writing to a DB4 file dharp Excel Programming 2 August 18th 06 04:25 PM
Writing a CSV file guy Excel Programming 2 January 21st 05 09:57 AM
Writing to a file from excel Cesar Zapata[_2_] Excel Programming 2 October 15th 04 05:48 PM
Writing a .txt file Claus[_2_] Excel Programming 2 September 27th 04 01:47 AM
file writing Mike[_49_] Excel Programming 0 November 22nd 03 06:57 PM


All times are GMT +1. The time now is 01:14 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"