12-20-2023 11:18 AM
Hi Everyone.
I have a DataCell that ends with a comma, and I wanted to know how I can remove it.
Example
Etc.
UD6Id: -999,
UD7Id: -999,
UD8Id: -999,
My issue is similar to the example, where after the UD8Id there is a comma with nothing following.
Solved! Go to Solution.
12-20-2023 11:45 AM - edited 12-20-2023 03:07 PM
Hi Marco,
It would help if you post the code that is producing this. I'm going to assume you need to remove the last comma that is added using a loop that puts a comma at the end of a string on each iteration. To resolve the extra comma that results, you can add(use whatever variable name you are using now for "strDataCellMembers"):
strDataCellMembers = strDataCellMembers.TrimEnd(",", c)
Often a better approach is to create a List(Of String) and add the datacell member scripts to the list in your loop. Then add the commas like this:
Dim strDataCell As String = String.Join(",", lstDataCellElements)
This approach eliminates the need to manage the last extra comma that looping and appending a string or stringbuilder has.
12-20-2023 11:45 AM - edited 12-20-2023 03:07 PM
Hi Marco,
It would help if you post the code that is producing this. I'm going to assume you need to remove the last comma that is added using a loop that puts a comma at the end of a string on each iteration. To resolve the extra comma that results, you can add(use whatever variable name you are using now for "strDataCellMembers"):
strDataCellMembers = strDataCellMembers.TrimEnd(",", c)
Often a better approach is to create a List(Of String) and add the datacell member scripts to the list in your loop. Then add the commas like this:
Dim strDataCell As String = String.Join(",", lstDataCellElements)
This approach eliminates the need to manage the last extra comma that looping and appending a string or stringbuilder has.