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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Working with text files

Status
Not open for further replies.

GSMike

Programmer
Feb 7, 2001
143
US
I know how to open a txt file, and write to it, but how do you open a text file and setp through the characters one by one looking foor a specific character and then replace that character?
Thank for you rhelp.-=Mike Mike Kemp
kempm541145@yahoo.com
 
Hi.

open the file in binary mode: pseudocode follows
the data you get may be the ascii value not a string, it's a while since i used binary mode.

' get file length in bytes
' open the file in binary mode
' Dim a as String * 1
' for each character in file
' get #1, a
' If a = Chr(&H22) then ' this is a double quote
' a = "'" ' make it a single quote
' put# a 'etc
' end if
' next

otherwise, access has ODBC support for text files as a database source....

Gzep.
 
Thank you, Gzep.
I managed to get the job done with:
Sub Mike()
Code:
Dim fs, str_1 as string
set a=fs.opentextfile("c:\myfile.text")
do while a.atendofstream=false
     str_1=str_1&vbcrlf&a.readline
loop
open "c:\mynewfile.txt" for outoput as #
print #1, str_1
reset
end sub
YOur is much more character=specific. I am sure I will be able to use it in the future.
Thanks again. Mike Kemp
kempm541145@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top