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

Extracting a word from a text file? Please, HELP!

Status
Not open for further replies.

rferrer61

IS-IT--Management
Jul 5, 2001
8
US
Hi there,
I know how to clear the blank spaces from a text file and how to get the amount of characters in my text file. However, I would like to be able to extract a word which change every time I create my text file.
Any ideas?
Thank You in advance,

RF
 
Read in the file with one command. I use the FileSystemObject.
Dim strFileData As string
Dim strFileIn As String
strFileIn = "C:\In.txt"
strFileOut = "C:\Out.txt"

strFileData = ReadProto(strFileIn)
strFileData = Replace(strFileData,"MyWord","NewWord",vbTextCompare)
WriteProto strFileOut, strFileData, ForWriting
Private Function ReadProto(strFileName As String) As String
Dim objFS As FileSystemObject
Dim objTS As TextStream

Set objFS = New FileSystemObject
Set objTS = objFS.OpenTextFile(strFileName, _
ForReading, False, TristateFalse)
ReadProto = objTS.ReadAll
objTS.Close
Set objTS = Nothing
Set objFS = Nothing
End Function
Private Sub WriteProto(strFileName As String, _
strOut As String, _
lngIoMode As IOMode)
Dim objFS As FileSystemObject
Dim objTS As TextStream

Set objFS = New FileSystemObject
Set objTS = objFS.OpenTextFile(strFileName, _
lngIoMode, True, TristateFalse)
objTS.Write strOut
objTS.Close
Set objTS = Nothing
Set objFS = Nothing
End Sub
Generate Forms/Controls Resizing/Tabbing Class
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
By "need to extract" a word.... what do you mean?

Is it a particular word in a specific location or do you have to figure out if a word has changed and which one it is ?


Perhaps a statement of purpose at the business-problem level rather than what the program has to do would make it clearer.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top