Hi
I have a String of names and am adding them to a document to replace other text. I would like the names to be shown as a list
Name 1
Name 2
etc
Rather than a string - Name1, Name2, etc.
Is anyone able to help please.
Thanks
Raychel
Hi
I have a String of names and am adding them to a document to replace other text. I would like the names to be shown as a list
Name 1
Name 2
etc
Rather than a string - Name1, Name2, etc.
Is anyone able to help please.
Thanks
Raychel

Lets assume a flatten comma seprated string. We would split and join it with a Linebreak
String.Join(Environment.Newline,YourStringVar.Split(","c))
-First, you’ll need to split the original string into an array of names.
namesArray = originalNamesString.Split(","c)
-Next, you can use the String.Join method to join the names with newline characters to create the desired list format.
namesListString = String.Join(Environment.NewLine, namesArray)
-Finally, you can display the namesListString in a message box
MessageBox.Show(namesListString, "List of Names")
Cheers…!
In Addition to above, we can extend and also trim the splits

For a better readability we would split it to two steps
Assign Activity:
arrSplits =
YourStringVar.".Split(",".ToCharArray, StringSplitOptions.RemoveEmptyEntries).Select(Function (x) x.Trim())
Assign Activity
strList = String.Join(Environment.NewLine, arrSplits)
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.