Process text file, line by line

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • LesC
    New Member
    • Jun 2007
    • 4

    Process text file, line by line

    trying to get this code to loop through a text document line by line.

    [CODE=vb]Private Sub Command1_Click( )

    WordFoundFlag = 0
    For i = 1 To Len(Text1)
    Char = Mid(Text1, i, 1)
    If Char Like "[A-Za-z-]" And WordFoundFlag = 0 Then
    WordFoundFlag = 1
    StartPos = i
    ElseIf Char Like "[!A-Za-z-]" And WordFoundFlag = 1 Then
    ElseIf Char Like "[!0-9]" And WordFoundFlag = 1 Then
    GoTo BYE
    End If
    Next

    BYE:

    FindFirstWord = Mid(Text1, StartPos, i - StartPos)
    Text1 = Replace(Text1, FindFirstWord, "")

    End Sub[/CODE]

    Any HELP would be great
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    It would help if you could give us some idea of what the problem is.

    Comment

    • LesC
      New Member
      • Jun 2007
      • 4

      #3
      I am trying to remove the line numbers of a text document.

      Example:
      N10 G01 F720 X0Y0Z0
      N20 X0Y0Z0
      etc...
      N9000 X0Y0Z0
      M0

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        You've told us what you want to do, but not specifically what the problem is. Also, what version of VB are you using?

        Comment

        • LesC
          New Member
          • Jun 2007
          • 4

          #5
          i am using vb6 and as i said in my first post, i am trying to use tne code that i posted but can only get it to work on the first line and i need it to do the entire document.

          thank you
          les

          Comment

          • Killer42
            Recognized Expert Expert
            • Oct 2006
            • 8429

            #6
            Well, if you have a look in the index at the top of the VB forum there are a couple of samples showing how to read a text file. One of them reads line by line. So you could take that and adapt it to call your routine for each line.

            Comment

            • LesC
              New Member
              • Jun 2007
              • 4

              #7
              Thank You, will give it a try

              Comment

              Working...