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!

Search word in Text file

Status
Not open for further replies.

Cap2010

Programmer
Mar 29, 2000
196
CA
Want to [red]search a word from a text file[/red], having a sentences. The procedure below has the [red]variable CHECK[/red] that extracts a sentence from 44.txt file and in that sentence, [red]variable DATA (having a word)[/red] is checking the word, which the following code doesn't do and
the record pointer of file 44.txt doesn't goes to second line. It has the [red]following 2 errors[/red]

[red] 1) To check word from a sentence
2) To record pointer to move next line in file 44.txt[/red]


Private Sub Command1_Click()
Dim FileKey As String
Dim FileNews As String

Dim Data As String
Dim Check As String

Dim counter As Integer

FileKey = "d:\my documents\keyword.txt"
Open FileKey For Input As #1

FileNews = "d:\my documents\44.txt"
Open FileNews For Input As #2

Do Until EOF(2)
Line Input #1, Data
Line Input #2, Check

If Data = check Then
Text1.Text = Text1.Text & vbCrLf & Data
counter = counter + 1
Else
'MsgBox "not found"
End If
Loop
Close #1, #2
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top