Instr(blah)

x39rox
09-02-2003, 08:16 PM
All I need to do is open a text file, look for a specific word, and when its found, put the line that the word is on into a string. I think it has to do with 'sLine'. Thanks.

zoul1380
09-02-2003, 08:20 PM
Use instr

x39rox
09-02-2003, 08:23 PM
Ok? I know how to look for the word, but I just need to know how to put the line that the word i searched for, into a string.

Squishy
09-02-2003, 08:29 PM
If you used, for example, Instr(blah), where blah is a variable, then blah without the Instr function will return the entire line (e.g. Text1.Text = blah).

passel
09-02-2003, 08:38 PM
You mean something along these lines.

Dim a As String
Open "file.txt" For Input As #1
Do Until EOF(1)
Line Input #1, a
If InStr(a$, "blah") Then
Debug.Print a$
End If
Loop
Close #1

x39rox
09-02-2003, 08:47 PM
Dude yes, you own. Thanks, worked perfect.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum