VB6 - multiple lines from a notepad.txt into a single lines?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • PuvanRajan1984
    New Member
    • Jan 2023
    • 1

    VB6 - multiple lines from a notepad.txt into a single lines?

    How do i convert multiple lines from a notepad.txt into a single lines?
  • BloomS
    New Member
    • Jan 2023
    • 8

    #2
    You can use a text editor or text processing tool to convert multiple lines from a notepad.txt file into a single line. You may also be able to use a command line utility such as sed or awk to accomplish this.

    Comment

    • KRITGuy
      New Member
      • Jul 2023
      • 6

      #3
      Open in Binary mode. Read the entire file into A$

      A$ = Replace(A$, vbCrLf, "<BR>")

      That would likely resolve it for you.

      Play with this simple snippet :-)

      A$ = "Hello " & vbCrLf
      A$ = A$ & "World" & vbCrLf

      A$ = Replace(A$, vbCrLf, "<BR>")

      Cheers,
      Kevin

      Comment

      • KRITGuy
        New Member
        • Jul 2023
        • 6

        #4
        Though this may be better

        A$ = "Hello " & vbCrLf
        A$ = A$ & "World" & vbCrLf

        A$ = Replace(A$, vbCr "")
        A$ = Replace(A$, vbLf, "<BR>")

        (Just in case)

        :-)

        Comment

        • erikbower65
          New Member
          • Jul 2023
          • 12

          #5
          To convert multiple lines from a notepad.txt file into a single line, you can follow these steps:

          1. Open the notepad.txt file in a text editor.

          2. Select and copy the contents of the file.

          3. Open a new blank document or text editor window.

          4. Paste the copied text into the new document.

          5. Replace line breaks with a space or any other separator of your choice. The method for replacing line breaks may vary depending on the text editor you are using.

          > In most text editors, you can use the find and replace function (typically Ctrl + H or Command + H) to find line breaks (represented as "\n" or "\r\n") and replace them with a space or another desired separator.

          > If your text editor supports regular expressions, you can search for "\r?\n" (for Windows-style line breaks) or "\n" (for Unix-style line breaks) and replace them with a space or desired separator.

          6. Once you've replaced the line breaks, you should have the text from the notepad.txt file in a single line.

          7. Save the modified text as a new file or overwrite the original notepad.txt file.

          Remember to keep a backup of the original file before making any modifications to ensure you don't lose any data.

          Comment

          • KRITGuy
            New Member
            • Jul 2023
            • 6

            #6
            The use of backslash variables is not bad, rather than the HTML "<BR>" of course.

            The reason I went with the "Replace" function is that this was raised as a VB6 Question :-)

            This suggests that the question was intended to achieve a programmatic response in VB6.

            But yes, I do prefer your backslash variables :-)

            Cheers,
            Kevin

            Comment

            Working...