Conversion from string to integer formats

I’m storing values ​​that I need to validate in a variable as a string, in one of the values ​​that I need to validate, I’m using the formula below to convert it to an integer:

StrValue = (Convert.ToDouble (StrColValor3) + Convert.ToDouble (StrColValor)).

For the sequence a value appeared in the 9,999.99 format and an error occurred that “The entry was not in the correct format” the other values ​​that always appear are in this format 23,23 for example.

Is there another formula that I can convert string to integer and this error does not occur?

Have you tested with CDbl("9,999.99") instead?

1 Like

If your provided examples are correct (9,999.99 and 23,23) then the problem is decimal/thousands separator.

You should use corect decimal/thousands separator in your string in order to fix error.
It should be accoding to your locale settings.

Cheers

@lourena.coutinho
have a look here as it is very close to your case:

more down you will get some sample on how to get control on the parsing and formats. Also it is mentioned on how to check if parsing possible or not.

Please try using assign activity for integervariablename=cint(stringvariablename). This must work fine.

Hello @lourena.coutinho,

Try assign: StrValue1 = Covert.ToDouble(StrCovValor3,System.Globalization.CultureInfo.InstalledUICulture)

Assign: StrValue2 = Covert.ToDouble(StrCovValor,System.Globalization.CultureInfo.InstalledUICulture)

After that, you need to use your country “method”

For example: Write cell activity:

StrColValor3.ToString(new CultureInfo(“es-ES”)) + StrColValor.ToString(new CultureInfo(“es-ES”))

I am from Spain, so I would use “es-ES”. It is important to import system.globalisation here:

image

I hope it helped! :slight_smile:

Angel

1 Like