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?
ptrobot
October 23, 2020, 10:21am
2
Have you tested with CDbl("9,999.99")
instead?
1 Like
J0ska
October 23, 2020, 11:09am
3
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
ppr
(Peter Preuss)
October 23, 2020, 11:26am
4
@lourena.coutinho
have a look here as it is very close to your case:
Hello all
I am facing a issue with converting a variable from string to integer. The robot reads a range from excel and then i assign each column to a variable: row(x).ToString. One column (“Amount”) is composed by amounts. So the robot reads this amounts as string and I do the following steps:
Assign activity → Value = Cint(“Amount”)
Write cell act → Value * -1
Doing that, i get this message error in the assign activity: Asignar: Conversion from string “55.358,61” to type ‘In…
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:
I hope it helped!
Angel
1 Like