:confused: How do you .txt files and search data in them?? :confused:
Printable View
:confused: How do you .txt files and search data in them?? :confused:
this is how you .txt them (save them):
and this is how you open them, and search them:Code:text1.text = "Hello World"
Open "C:\windows\desktop\hello.txt" for output as #1
Write #1, text1.text
Close #1
Code:'to open the file
Open "C:\windows\desktop\hello.txt" for input as #2
Input #2, text1.text
Close #2
'to search it
if intstr(text1.text, "Hello World") then
msgbox "found hello world"
end if
Visual Programmer
How do you .txt files? <-what's this mean?
To search data in them, open them and search:
Code:Private Sub Command1_Click()
Dim MyVarString As String
Open "C:\TxtFile.txt" For Input As #1
MyVarString = Input(LOF(1), 1)
If InStr(1, MyVarString, "string") Then
MsgBox "File contains 'string'"
Else
MsgBox "'string' not found"
End If
Close #1
End Sub
Use the Print # Statement rather than the Write # Statement.Quote:
Originally posted by Visual Programmer
this is how you .txt them (save them):
Code:text1.text = "Hello World"
Open "C:\windows\desktop\hello.txt" for output as #1
Write #1, text1.text
Close #1
The Write # Statement will put quotes ("") around the words of the file.
The Print # Statement will write text with no quotes ("") around the file.
Thanks for the tips