Connect with Expertise | Find Experts, Get Answers, Share Insights

Parse field that contains \n as a delimiter

 
Join Date: Dec 2007
Posts: 55
#1: Jan 28 '10
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\nDescription :\n\nThere is a report of volnerability\nthis 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.

✓ answered by missinglinq

How about
Expand|Select|Wrap|Line Numbers
  1. =Replace(Me.TargetString, "\n", vbNewLine)
Linq ;0)>

beacon's Avatar
C
 
Join Date: Aug 2007
Posts: 385
#2: Jan 28 '10

re: Parse field that contains \n as a delimiter


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.
 
Join Date: Dec 2007
Posts: 55
#3: Jan 28 '10

re: Parse field that contains \n as a delimiter


good idea i'll give it a try
beacon's Avatar
C
 
Join Date: Aug 2007
Posts: 385
#4: Jan 28 '10

re: Parse field that contains \n as a delimiter


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.
missinglinq's Avatar
E
C
 
Join Date: Nov 2006
Location: Richmond, Virginia USA
Posts: 3,380
#5: Jan 28 '10

re: Parse field that contains \n as a delimiter


How about
Expand|Select|Wrap|Line Numbers
  1. =Replace(Me.TargetString, "\n", vbNewLine)
Linq ;0)>
NeoPa's Avatar
E
M
C
 
Join Date: Oct 2006
Location: London - UK
Posts: 18,893
#6: Jan 30 '10

re: Parse field that contains \n as a delimiter


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.
missinglinq's Avatar
E
C
 
Join Date: Nov 2006
Location: Richmond, Virginia USA
Posts: 3,380
#7: Jan 30 '10

re: Parse field that contains \n as a delimiter


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)>
NeoPa's Avatar
E
M
C
 
Join Date: Oct 2006
Location: London - UK
Posts: 18,893
#8: Jan 30 '10

re: Parse field that contains \n as a delimiter


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 :)
missinglinq's Avatar
E
C
 
Join Date: Nov 2006
Location: Richmond, Virginia USA
Posts: 3,380
#9: Jan 31 '10

re: Parse field that contains \n as a delimiter


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)>
Delerna's Avatar
E
C
 
Join Date: Jan 2008
Location: Sydney
Posts: 1,062
#10: Jan 31 '10

re: Parse field that contains \n as a delimiter


Oh no! I haven't thought about quick basic in decades, now it all comes flooding back.
NeoPa's Avatar
E
M
C
 
Join Date: Oct 2006
Location: London - UK
Posts: 18,893
#11: Feb 1 '10

re: Parse field that contains \n as a delimiter


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.
 
Join Date: Dec 2007
Posts: 55
#12: Feb 5 '10

re: Parse field that contains \n as a delimiter


thanks missinglinq... your suggestion did the trick
missinglinq's Avatar
E
C
 
Join Date: Nov 2006
Location: Richmond, Virginia USA
Posts: 3,380
#13: Feb 5 '10

re: Parse field that contains \n as a delimiter


Glad we could help!

Linq ;0)>
Reply

Tags
acces, parse