By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,501 Members | 2,861 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,501 IT Pros & Developers. It's quick & easy.

Parse field that contains \n as a delimiter

P: 55
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.
Jan 28 '10 #1

✓ answered by missinglinq

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

Share this Question
Share on Google+
12 Replies


beacon
100+
P: 579
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.
Jan 28 '10 #2

P: 55
good idea i'll give it a try
Jan 28 '10 #3

beacon
100+
P: 579
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.
Jan 28 '10 #4

missinglinq
Expert 2.5K+
P: 3,532
How about
Expand|Select|Wrap|Line Numbers
  1. =Replace(Me.TargetString, "\n", vbNewLine)
Linq ;0)>
Jan 28 '10 #5

NeoPa
Expert Mod 15k+
P: 31,494
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.
Jan 30 '10 #6

missinglinq
Expert 2.5K+
P: 3,532
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)>
Jan 30 '10 #7

NeoPa
Expert Mod 15k+
P: 31,494
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 :)
Jan 30 '10 #8

missinglinq
Expert 2.5K+
P: 3,532
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)>
Jan 31 '10 #9

Delerna
Expert 100+
P: 1,134
Oh no! I haven't thought about quick basic in decades, now it all comes flooding back.
Jan 31 '10 #10

NeoPa
Expert Mod 15k+
P: 31,494
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.
Feb 1 '10 #11

P: 55
thanks missinglinq... your suggestion did the trick
Feb 5 '10 #12

missinglinq
Expert 2.5K+
P: 3,532
Glad we could help!

Linq ;0)>
Feb 5 '10 #13

Post your reply

Sign in to post your reply or Sign up for a free account.