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

Replace string in text file

Status
Not open for further replies.

denko

Programmer
May 17, 2001
70
0
0
US
Hello,
How can i replace one line in the Text file with another without deleting any other lines in the file?
Example:

F444AF02050 03/05/31 09:56:19
188579Y101 XXX 88579Y10118M
188579Y101 BBB 88579Y10118M
188579Y101 ZZZ 88579Y10118M

Need to replace date in the first line

F444AF02050 02/05/30 09:56:19
188579Y101 XXX 88579Y10118M
188579Y101 BBB 88579Y10118M
188579Y101 ZZZ 88579Y10118M

Thanks
 
Well, my crudest method would be:

Const cstrDate As String = "02/05/30"
Dim str As String * 1
Dim intFile As Integer

intFile = FreeFile
Open "C:\My Documents\TEST.TXT" For Random As intFile Len = Len(str)
For lng = 1 To Len(cstrDate)
str = Mid(cstrDate, lng, 1)
Put #intFile, 12 + lng, str
Next lng
Close intFile

I pasted in your source data using notepad and successfully overwrote the characters in the source date.

Hope this helps.



Andy
"Logic is invincible because in order to combat logic it is necessary to use logic." -- Pierre Boutroux
"Why does my program keep showing error messages every time something goes wrong?"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top