|
-
Dec 16th, 2000, 11:32 PM
#1
Thread Starter
Junior Member
How do you .txt files and search data in them??
Eric - ComputerWiz6996
Live long... Live well... Code Alot 
-
Dec 16th, 2000, 11:47 PM
#2
Member
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
and this is how you open them, and search them:
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
VP/Sonic taking on the (vb) world, one post at a time.
-
Dec 16th, 2000, 11:47 PM
#3
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
-
Dec 16th, 2000, 11:51 PM
#4
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
Use the Print # Statement rather than the Write # Statement.
The Write # Statement will put quotes ("") around the words of the file.
The Print # Statement will write text with no quotes ("") around the file.
-
Dec 17th, 2000, 12:10 AM
#5
Member
VP/Sonic taking on the (vb) world, one post at a time.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|