Parse field that contains \n as a delimiter

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • barmatt80
    New Member
    • Dec 2007
    • 55

    Parse field that contains \n as a delimiter

    We have a program that runs on a linux machine that outputs a text file. The description field has \n as line breaks.

    here is an example:

    \nSynopsis :\n\nError on machine.\n\nDes cription :\n\nThere is a report of volnerability\n this would make the computer at risk\nSolution :\n\nSolution:\ nInstall new patches

    Is there a way to make the \n as line breaks on a report or form?

    I currently just have an imported table that has a findingID and then the description, which is the data above.
  • beacon
    Contributor
    • Aug 2007
    • 579

    #2
    Hi barmatt,

    Have you tried using the character codes for carriage return and line feed if "/n" is in the string?

    I've added textboxes to reports and if I add "Chr(13) & Chr(10)" to the textbox it will do a break. I would think that you should be able to setup something similar using the instr and replace functions to accomplish your task.

    Comment

    • barmatt80
      New Member
      • Dec 2007
      • 55

      #3
      good idea i'll give it a try

      Comment

      • beacon
        Contributor
        • Aug 2007
        • 579

        #4
        FYI...be careful when using "Chr(13) & Chr(10)" in a textbox (can't be a label) on your report. I've had mixed results in the past if I only used "Chr(13)" or "Chr(10)" without the other to accompany it.

        Comment

        • missinglinq
          Recognized Expert Specialist
          • Nov 2006
          • 3533

          #5
          How about
          Code:
          =Replace(Me.TargetString, "\n", vbNewLine)
          Linq ;0)>

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32634

            #6
            Interesting. I've always used vbCrLf, but it seems that is exactly the same as vbNewLine (which I didn't know about). That should certainly do the trick anyway. Essentially what Beacon was proposing, but using the inbuilt named values instead.

            Comment

            • missinglinq
              Recognized Expert Specialist
              • Nov 2006
              • 3533

              #7
              I like vbNewLine because it's easy to remember and it does exactly what its name suggests, not always the case in VBA!

              Linq ;0)>

              Comment

              • NeoPa
                Recognized Expert Moderator MVP
                • Oct 2006
                • 32634

                #8
                Coming from the days where CR & LF were used individually (but together) the vbCrLf always made sense to me, but I can see why vbNewLine would appeal generally. I'm inclined to agree it's a more general and easily understood version. I may just have to switch now I've learned about it :)

                Comment

                • missinglinq
                  Recognized Expert Specialist
                  • Nov 2006
                  • 3533

                  #9
                  You're telling your age now, NeoPa! I , too, come from that time! I started coding in QuickBasic 4.5, which was later used as the engine for VB and hence VBA. When people complain about how hard it is to do this or that in VBA I just have to laugh! I remember having to write a page-and-a-half of code to add a given number of weeks to a date! VBA is way more powerful than most people realize!

                  Linq ;0)>

                  Comment

                  • Delerna
                    Recognized Expert Top Contributor
                    • Jan 2008
                    • 1134

                    #10
                    Oh no! I haven't thought about quick basic in decades, now it all comes flooding back.

                    Comment

                    • NeoPa
                      Recognized Expert Moderator MVP
                      • Oct 2006
                      • 32634

                      #11
                      Although I came across some versions of BASIC in my earlier career, the time I'm talking about I hadn't done any. At that time it was all Assembler, COBOL & RPGII. When I moved on to C in the early 80s they introduced the \n, which handled new lines, but it was far less hardware dependent by then.

                      Comment

                      • barmatt80
                        New Member
                        • Dec 2007
                        • 55

                        #12
                        thanks missinglinq... your suggestion did the trick

                        Comment

                        • missinglinq
                          Recognized Expert Specialist
                          • Nov 2006
                          • 3533

                          #13
                          Glad we could help!

                          Linq ;0)>

                          Comment

                          Working...