A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Reading From and Writing To text files



 
 
Thread Tools Display Modes
  #1  
Old February 17th, 2009, 06:52 PM posted to microsoft.public.access.gettingstarted
Bre-x
external usenet poster
 
Posts: 103
Default Reading From and Writing To text files

Hi,
I need to open a text file

if my code finds on the 3 Line (Always the 3 Line)
the text "(FN-", I need to replace it with "(FX-"

if the finds something else
I need to insert a line after the 2 and enter "(FX-"

Is there a way to do this?



Function insert_fnpath()
Dim fso As New Scripting.FileSystemObject
Dim thepath As String
Dim ftext
Dim ntext

thepath = "N:\1CNC\DATA\625\FISCON0100\6252018.txt"

Set ftext = fso.OpenTextFile(thepath, ForReading)

x = ftext.ReadLine
ftext.SkipLine
x = ftext.Read(4)
ftext.Close

Select Case x

Case "(FN-"
'Overwrite line with "(FX-)


Case Else
'Insert New Line after Line 2

End Select

Set fso = Nothing

end Function


  #2  
Old February 17th, 2009, 11:41 PM posted to microsoft.public.access.gettingstarted
Larry Daugherty
external usenet poster
 
Posts: 1,012
Default Reading From and Writing To text files

Look in VBA Help for the Open statement. It gives you enough
information to manage the file I/O. You need to use VBA to manipulate
the strings and do the rest of what you want.

The File I/O components work in all dialects of BASIC.

HTH
--
-Larry-
--

"Bre-x" wrote in message
...
Hi,
I need to open a text file

if my code finds on the 3 Line (Always the 3 Line)
the text "(FN-", I need to replace it with "(FX-"

if the finds something else
I need to insert a line after the 2 and enter "(FX-"

Is there a way to do this?



Function insert_fnpath()
Dim fso As New Scripting.FileSystemObject
Dim thepath As String
Dim ftext
Dim ntext

thepath = "N:\1CNC\DATA\625\FISCON0100\6252018.txt"

Set ftext = fso.OpenTextFile(thepath, ForReading)

x = ftext.ReadLine
ftext.SkipLine
x = ftext.Read(4)
ftext.Close

Select Case x

Case "(FN-"
'Overwrite line with "(FX-)


Case Else
'Insert New Line after Line 2

End Select

Set fso = Nothing

end Function




 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 02:06 AM.


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