Insert new line in string

Hello guys,
Is it possible to insert a new line character in a string?
I found online something like “vbclrf” but that doesn’t work.

I want to concatenate multiple entries from a DataTable, send them to Clipboard and then send them to SAP via the “Copy from Clipboard” option.

Thanks in advance

Did you check this?

Hello,

Either Vbnewline or Environnement.newline should achieve what you want to do.

ex: str = Row1 & vbNewLine & Row2

Cheers

6 Likes

Indeed, vbnewline did the job, thank you for that.

In case anyone else stumbles upon this thread, another solution that I found for SAP is writing Vertical Line (Ascii 13) and then BackSpace (Ascii 10). Don’t know the logic behind it, but it seemed to work

2 Likes

I’m getting an error when I try to use Environment.NewLine:

'NewLine' is not a member of 'UiPath.Core.GenericValue'.

Hi @PetreN, is VbCrLf not vbclrf. And if you cant summon this, you should import some library i guess… but try it because you will be able.

Just like:
“Hi, this is my first line”+VbCrLf+“And now im in the second line”+VbCrLf+“End at the third”

6 Likes

VbCrLf this works, I have tested this
Thanks @poblo_sanchez

4 Likes

NewLine returns a string. You may need to make sure the variable type is String, not GenericValue. Hope that helps,

1 Like

Gracias!!

1 Like

Con vbcr sobra😁

Another Option: ex: str = Row1 & Environment.NewLine & Row2

I know this is necro, but, ASCII 13 = CR (carriage return) and ASCII 10 = Linefeed AKA CrLf (vbCrLf is just a shortcut object for this combination). This was the old school way of doing it - CHR(13) & CHR(10). Just in case thread is stumbled upon.

1 Like

I use vbCrLf frequently and it works just fine. But sometimes when I modify my workflow I suddenly get ‘vbCrLf’ is not declared. It may be inaccessible due to its protection level. This also happened with TimeOfDay - same issue. I ran just fine using these two until I had to add a few items to my workflow and suddenly I’m breaking all over the place with those messages. I had to change to Environment.NewLine and DateTime.Now.ToString. So frustrating!

2 Likes

@MarySue the latter way is recommended anyways since it is environment agnostic and it also is much more readable :slight_smile:

2 Likes

NewString= String1 + Environment.NewLine + String2