CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2001
    Location
    Minneapolis, MN, USA
    Posts
    150

    searching a text file

    Does anyone know how to programmatically open an existing text file. Then search through a comma delimited file(like the portion below) for a string, '475'.

    16,301,13981439,Z,IA0010,012040/
    16,301,4756071,Z,IA00045,000000/
    16,475,72363175,Z,IA00025,012040/
    16,475,42736600,Z,IA00025,012050/

    Thank you

    No L c
    VB Developer

  2. #2
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: searching a text file

    Dim sLine As String
    Dim aryInput() As String
    Dim i As Integer


    Open "c:\file.txt" For Input As #1 'to read from
    Do While Not EOF(1)
    Line Input #1, sLine
    aryInput = Split(sLine,",")
    For i = LBound(aryInput) To UBound(aryInput)
    if aryInput(i) = '475' then
    ...do something
    end if
    Next


    Loop
    Close #1


    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  3. #3
    Join Date
    Aug 2001
    Location
    Minneapolis, MN, USA
    Posts
    150

    Re: searching a text file

    thank you for the response

    No L c
    VB Developer

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

Featured