+ Reply to Thread
Results 1 to 3 of 3

Help with Carriage Control & Line feed characters

  1. #1
    Registered User
    Join Date
    04-27-2023
    Location
    California
    MS-Off Ver
    2016
    Posts
    2

    Help with Carriage Control & Line feed characters

    Hello

    I have a script that writes out a file based on data in the spreadsheet. I use the 'write' function as follows:

    Please Login or Register  to view this content.
    When I open the resulting file in Notepad++ & turn on hidden characters, I see that there is indeed an LF character where I expect one. Perfect!

    Now instead of a file, I want to write everything to a string variable, & save it in a random cell. I create a new sub addLine(), which appends the input string to string variable 'fileString' which is global to the module.

    Please Login or Register  to view this content.
    Then I simply replace every instance of "adf.Write (" with "addLine (":

    Please Login or Register  to view this content.
    I copy the resulting string from the cell I saved it to and paste it into Notepad++. It looks exactly like the file I wrote earlier, EXCEPT that in place of just an LF character where I expect it, I now get a CR character proceeding the LF character.

    I have tried char(10) instead of vbLF which makes no difference. If I omit the '& vbLf' I get no LF or CR (as I would expect). So in the context of strings, a vbLf seems to have exactly the same effect as a vbCrLf. Very inconsistent.

    I already don't have that much hair, so any suggestions would be greatly appreciated!

    Thanks in advance!

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,623

    Re: Help with Carriage Control & Line feed characters

    but where is fileString declared?
    Please Login or Register  to view this content.
    Is it a public variable? if not it is local to procedure, and is not used, just has the value assigned and disappears after End Sub is reached.
    Best Regards,

    Kaper

  3. #3
    Registered User
    Join Date
    04-27-2023
    Location
    California
    MS-Off Ver
    2016
    Posts
    2

    Re: Help with Carriage Control & Line feed characters

    Thanks Kaper!

    Yes, "I create a new sub addLine(), which appends the input string to string variable 'fileString' which is global to the module."

    towtruck

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Carriage Return / Line feed append to end of formula
    By ggarmento in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 07-13-2018, 03:20 PM
  2. While saving as CSV, need a carriage return/line feed
    By Ash Gajjar in forum Excel General
    Replies: 0
    Last Post: 11-06-2013, 12:17 PM
  3. Forcing a line feed within a cell (Carriage Return)
    By Marcus Gee in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-18-2013, 11:24 AM
  4. Carriage Return Line Feed
    By wlcummings in forum Access Programming / VBA / Macros
    Replies: 0
    Last Post: 02-18-2011, 05:03 PM
  5. Replies: 8
    Last Post: 11-07-2008, 09:26 AM
  6. [SOLVED] How do I remove multiple line feed(s) or carriage return(s)?
    By sra in forum Excel General
    Replies: 1
    Last Post: 05-24-2005, 07:06 PM
  7. [SOLVED] [SOLVED] Find/Replace carriage return & line feed characters in Excel.
    By Mary Cullen in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-04-2005, 04:06 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1