Results 1 to 5 of 5

Thread: How do you .txt files and search data in them??

  1. #1

    Thread Starter
    Junior Member ComputerWiz6996's Avatar
    Join Date
    Dec 2000
    Location
    Tampa, FL
    Posts
    31

    Question

    How do you .txt files and search data in them??
    Eric - ComputerWiz6996

    Live long... Live well... Code Alot

  2. #2
    Member Visual Programmer's Avatar
    Join Date
    Dec 2000
    Posts
    59
    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.

  3. #3
    Guest
    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

  4. #4
    Guest
    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.

  5. #5
    Member Visual Programmer's Avatar
    Join Date
    Dec 2000
    Posts
    59
    Thanks for the tips
    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
  •  



Click Here to Expand Forum to Full Width