Want to round of string value

Hi All,

I want to round of string value which i am getting from SAP as example 2.234.54,94 want to round of to 223455.

Thanks in advance…!

Hi @amruta_pawar

We can use Math.Round() for round the number.

Regards
Anand

Is this string format correct buddy
Kindly check that once
If we want to round off a string with decimal then

Math.Round(Convert.ToDouble(strinput.ToString))

Cheers @amruta_pawar

Math.Round(Convert.ToDecimal("2.234.54,94", System.Globalization.new CultureInfo("fr-FR")), 2)

getting error as “)” expected.

its throwing error as invalid input format of string.

As @Palaniyappan mentioned, did you check the string. It does not seem to be in right format of number although it is in String format.

bot is for china and i am getting value in same format as i mentioned, no idea what to do.

So is it like 223454.94
@amruta_pawar

yeah

Then this expression would help you resolve this
strinput = strinput.ToString.Replace(“.”,””).Replace(“,”,”.”)

And
Then
Str_output = Math.Round(Convert.ToDouble(strinput.ToString)).ToString

Cheers @amruta_pawar

It worked thanks

Cheers @amruta_pawar

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