Append Comma to String Value

Hello Everyone,

I need a some help about for a append comma in string value.
Have a value set like this,

4198525
500000000
2410283
2000000
1918191
1000000
1000000
2642582

and i want to convert to like this,

41985,25
5000000,00
24102,83
20000,00
19181,91
10000,00
10000,00
26425,82
image

I need to add a comma before the last two digits of the value. how can I do that?
Thank you so much!

Hello,

You could loop through them and do a String.Insert

@korhansuren

Try the below expression
MyValue = ((Double.Parse(MyTestSTring,System.Globalization.CultureInfo.CreateSpecificCulture(“ES-es”))).ToString(“F2”,System.Globalization.CultureInfo.CreateSpecificCulture(“ES-es”)))

Hi
The expression be like this
If str_input = “4198525”
Then In assign activity
str_output = 41985,25
str_input.ToString.Insert(cint(str_input.ToString.Length)-2,”,”).ToString)

Regards,
Dhanush

Hey @korhansuren ,

Try this way

Thanks,
Sanjit

First of all thanks for your suggestion. I get this error when I do what you said.

I get the same error message for this way.

For Each: Unable to cast object of type ‘System.Char’ to type ‘System.String’.

Hi

Change the for each activity type object to string

Regards,
Dhanush

Hi,

It’s already set for string.

Hi

can you please share the xaml file then i can check the issue.

Regards,
Dhanush

Hello @korhansuren
Have you tried this method? Does it gave any error to you?

DBS_Limit_Report.zip (12.8 KB)
here’s the project file.
Thank you!

Hello,

acctually, I don’t quite understand how to implement this example. so we didn’t try.

hello @korhansuren ,

Inside your for loop you need to assign this value
image

As explained by @Dhanush_Naik in that example use
item(“columnName”) = ((Double.Parse(item(“columnName”).ToString,System.Globalization.CultureInfo.CreateSpecificCulture(“ES-es”))).ToString(“F2”,System.Globalization.CultureInfo.CreateSpecificCulture(“ES-es”)))

This will convert the existing value to required value format in your Data table

Regards,
Rohith

1 Like

Hi

Sample20220818-4 (2).zip (72.7 KB)
Please change the range

Regards,
Dhanush

You are looping on value_dt_str which is invalid in your case as this would store single character in loop variable item.
You should use for each row in datatable and loop over value_dt, inside loop assign respective columns current value to a variable say temp_str; e.g. temp_str = CurrentRow(“column name or index”).

then you can use insert function on temp_str;

temp_str.ToString.Insert(cint(temp_str.ToString.Length)-2,”,”).ToString)

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.