Results 1 to 3 of 3

Thread: FSO Question

  1. #1

    Thread Starter
    Hyperactive Member GamerMax5's Avatar
    Join Date
    Nov 2004
    Location
    United States
    Posts
    388

    Resolved FSO Question

    Is there any way to search through a text file for a string matching the string in a text box using FSO?
    Last edited by GamerMax5; Feb 11th, 2005 at 11:52 AM.
    Only those who try will become.

    Find me on identi.ca

    Twitter @gfmartin05

    Linux Wrap

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: FSO Question

    Why do you need to use the FSO? Try this:
    VB Code:
    1. Private Sub FindTextInFile(sStringToFind As String, sFileToLookIn As String)
    2.     Dim arrLinesArray() As String
    3.     Dim i As Long
    4.     Dim bIsItThere As Boolean
    5.    
    6.     'read file into array of lines
    7.     Open sFileToLookIn For Binary As #1
    8.         arrLinesArray = Split(Input(LOF(1), #1), vbCrLf)
    9.     Close #1
    10.     'search array line by line for text
    11.     bIsItThere = False
    12.     For i = LBound(arrLinesArray) To UBound(arrLinesArray)
    13.         If InStr(arrLinesArray(i), sStringToFind) > 0 Then
    14.             bIsItThere = True 'found it
    15.             Exit For
    16.         End If
    17.     Next
    18.     'let them know whats going on
    19.     If bIsItThere = True Then
    20.         MsgBox "The string " & sStringToFind & " was found on line: " & i & " in " & UCase(sFileToLookIn)
    21.     Else
    22.         MsgBox "The string " & sStringToFind & " was not found in " & UCase(sFileToLookIn)
    23.     End If
    24. End Sub
    25.  
    26. Private Sub Command1_Click()
    27. Call FindTextInFile("StringToFind", "c:\FileToFindItIn.txt")
    28. End Sub

  3. #3
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: FSO Question

    Quote Originally Posted by GamerMax5
    Is there any way to search through a text file for a string matching the string in a text box using FSO?
    I can't find any documentation on FSO having a search method.

    That certainly would be appropriate. I would imagine it's coming down the pike eventually - I've seen info about FSO being enhanced further in the future.

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