dcsimg
Results 1 to 3 of 3

Thread: [RESOLVED] [VBA EXCEL] Code is adding an 'ENTER' when doing replace

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2019
    Posts
    3

    Resolved [RESOLVED] [VBA EXCEL] Code is adding an 'ENTER' when doing replace

    Hi,
    I have a code that changes (replace) lines in txt, but when changing it puts an 'ENTER' at the end, I gave an F8 to see exactly where the problem is, and it is on the line:

    Print # 1, Replace (c0, Me.TxtAccessCurrent.Text, Me.TxtAccess.Text)


    This is the routine:
    Code:
    Private Sub ReplaceReleasesLISTBOX()
        Dim c0 As String
            Open ThisWorkBook.Path & "\access.txt" For Input As #1
            c0 = Input(LOF(1), #1)
            Close #1
        
            Open way & "\access.txt" For Output As #1
            Print #1, Replace(c0, Me.TxtAccessCurrent.Text, Me.TxtAccess.Text)
            Close #1
        MsgBox "success"
    
    End Sub

    Does anyone know why you are adding this 'ENTER'? And have a solution?

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    24,767

    Re: [VBA EXCEL] Code is adding an 'ENTER' when doing replace

    because print does that

    change to
    Code:
    Print # 1, Replace (c0, Me.TxtAccessCurrent.Text, Me.TxtAccess.Text);
    line continuation character at end
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    New Member
    Join Date
    Dec 2019
    Posts
    3

    Re: [VBA EXCEL] Code is adding an 'ENTER' when doing replace

    Perfect! Thanks a million

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width