Results 1 to 5 of 5

Thread: Searching through text file?

  1. #1

    Thread Starter
    Fanatic Member kinjalgp's Avatar
    Join Date
    Apr 2000
    Location
    India
    Posts
    535
    How do I seacrh a string through a text file and when the text is found, separate small strings separated by semicolon( and display them in different textboxex.

    Any help will be appreciated.
    Thanks in advance.

    Kinjal

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    give an example of your file please:
    Not the whole of it but 4 or 5 lines
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3
    Hyperactive Member
    Join Date
    Nov 1999
    Location
    Columbia, SC USA
    Posts
    374

    Cool

    Here's a good tip on the string parsing part

    http://www.vbsquare.com/tips/tip391.html

    As far as searching through the file, you could use the following code if your search criteria is equal to one line in the text file:

    Code:
    Dim fileName As String
    Dim Text As String
    Dim NewString As String
    
    fileName = 'put the file access route here
    
    Open fileName For Input As #1
    
    Do While Not EOF(1)
         Line Input #1, Text
         If Text = myComparison Then 'look to see if the text equals the comparison
             NewString = ParseString(Text, ";", 2)
             Exit Do
         End If
    Loop

    And yes, like HeSaidJoe requests, it will be helpful if you can post a few lines of the file and an example of what you might want to search for in the file.

  4. #4
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    that is one way..you could also just read it into an array and do your stuff...I think it depends on the information in the file and what you want to extract as to how it should be done. ex. are the Colons in the file? Is it a delimited file? etc.
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  5. #5

    Thread Starter
    Fanatic Member kinjalgp's Avatar
    Join Date
    Apr 2000
    Location
    India
    Posts
    535
    Yes you are right. My file is semi colon delimited file. I want to search the line containing certain number and when the number is found, separate out all different strings from the line and display them in text boxes.
    My file looks somewhat liek this:

    "1111";"ABCD";"Axzceydegwe1243";"hdsdgsadhvbd"
    "2222";"xzyx";"fkdffvjhdsfgsdfsdhdfdfdegwe";"jfdgfnbmvc"
    "3333";"pdskdhsfds";"fdsfduytuthdfdfdegwe";"weresadfnbmvc"


    Thanks

    Kinjal


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