I use Get Text and take two numbers from two fields. These numbers do not have the format (“1234”) but have the form e.g. (“13 435,31”). How can I change String “13 435,31” to Int and then add one variable to another ? It’s very hard for me
Use CInt to convert String variable into Integer variable.
Hope this expression would help you resolve this
If the input is in variable named str_input
Then use a assign activity like this
Int_output = CInt(str_input.ToString.Replace(“ “,””).Replace(“,”,””).Trim)
Your string cannot have spaces in them .
This will work: Convert.ToInt32("1234") But this will fail no matter what conversion method you use: Convert.ToInt32("12 34")
Therefore you have to remove the blank spaces first and then do the conversion.
This is the most basic way of doing it:
Convert.ToInt32(("12 34").Replace(" ",""))
Kindly retype from your end and check once
As I can see like the double quotes haven’t converted the strings
Ok, I used Get Text OCR and next Split function and I get string and can convert to Int, but after adding two Int variables, I convert the Int result to String and I need to add the “,” character before the last two digits? How can I do this ?
For example: I have String = “1045000” and I need add “,” before two last digits “10450,00”. The string not always have this same lenght, but I know how get lenght. I need only command to insert “,”
Str = "1045000" requiredStr = Str.Insert(Str.Length - 2, ",")
I don’t have Insert function Why ?
Make sure that variable should be of type String.
1)First print that variable value,
2)Replace spaces and comma with nothing and print again and check it is correct or not.
3)Then Convert to Integer and then print again for testing.
As cint(var.ToString.Replace(" “,”").Replace(",","").Trim) is working fine.
Try this @krzysztof.stanjek
yourNumberInInteger=cint(yourNumber. Replace(",","").Replace(" “,”"))
apply the same for another string and convert that to intger,and then perform arithmetic operations on integers.
right, it works now!
thanks gentlemen, my problem is solved
I have another problem. I want to read a number from a field in the program. I use two options.
First. Get Text OCR, the retrieved value is correct (for example “11 432,98”), I can edit it and remove blank space and other characters from it by the command - variable.Replace(" “,” “).Replace (”, ", ‘’)
Second. Double click on a field in the program and use Copy Selected Text activity. Then I check the value retrieved by the Write Line activity and looks the same as the first option, but with this method as I will use the command variable.Replace(" “,” “).Replace (”, ", ‘’) the character “,” is removed, but blank space remains and the program returns the error “Assign: Input string was not in a correct format.”
I was compare the variables of two methods by IF activity, I get information that they are not identical! Why is this happening?
I have to use the Copy Selected option
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.