Results 1 to 4 of 4

Thread: Delete Carriage return

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2000
    Posts
    3

    Lightbulb

    I am reading from a file and writing to another file.
    I am getting an extra carriage return, after reading
    from source. How could i delete extra carriage
    return at end of the file.

    Any light shed would be helpful.

    Thanks in advance

  2. #2
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Nitro
    Posts
    633
    t = Replace(txtFind.Text, vbCrLf, "")
    Chemically Formulated As:
    Dr. Nitro

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2000
    Posts
    3
    Still my problem is not solved. How do i know the
    End of file. i am reading the whole file and writing to another with different name and some changes. How could i use this code and know the end of file.
    i = Replace(file, vbCrLf, "")

    Thanks

  4. #4
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Nitro
    Posts
    633
    Drop two textboxes and a command button name:
    txtFind
    txtParagraph - set multiline = true
    cmdCarriageEliminator



    Code:
    Option Explicit
    
    Private Sub Form_Resize()
      'vbBack
      Me.WindowState = vbMaximized
      cmdCarriageEliminator.Caption = "Eliminate Only Single Carriage Return - Double Carriage Return Represent Separation of Paragraph"
      
      txtParagraph.Move 0, 0, Me.Width, Me.Height - cmdCarriageEliminator.Height * 3
      txtFind.Move 0, txtParagraph.Height + 240
      cmdCarriageEliminator.Move txtFind.Width + 120, txtParagraph.Height + 240, Me.Width - txtFind.Width - 120
      
      'PURPOSE:Eliminate the following
      txtFind.Text = vbCrLf
      
      'txtParagraph.ScrollBars = vbVertical
    End Sub
    
    Private Sub cmdCarriageEliminator_Click()
      'OVERALL:Search for txtFind.Text and delete it
      Dim intPos As Integer
      intPos = 1
      
      Do
          'PURPOSE:Look for txtFind.Text at the current intPos
          intPos = InStr(intPos, txtParagraph.Text, txtFind.Text)
          
          If intPos > 0 Then
              
              'PURPOSE:Check if intPos + Len(txtFind.Text) is another txtFind.Text
              '        If there are two txtFind.Text next too
              '        each other, do not delete it because it
              '        represent a line to separate a paragraph apart.
              If Mid(txtParagraph.Text, intPos + Len(txtFind.Text), Len(txtFind.Text)) = txtFind.Text Then
                'Increase the intPos to skip over
                intPos = intPos + Len(txtFind.Text) + Len(txtFind.Text)
              Else
                'PURPOSE:Replace txtFind.Text with a space
                txtParagraph.Text = Left(txtParagraph.Text, intPos - 1) & " " & Mid(txtParagraph.Text, intPos + Len(txtFind.Text))
              End If
              
          Else
              'PURPOSE:When there is no more txtFind.Text,
              '       intPos will equal 0 - Exist this sub
              Exit Sub
          End If
          
      Loop
    End Sub
    Chemically Formulated As:
    Dr. Nitro

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