How to get a numerical value of a text?

I’m using get visible text to get the text, but I would like to take the number 1 and convert it to integer. help me?

If MyIntStr is your captured integer string and MyInt is the integer form of it, use MyInt = CInt(MyIntStr.ToString.Trim).

2 Likes

I tried it that way, but I didn’t succeed.
I tried it like that too> CInt (item.ToString.Trim) = 0

What is the value of the scraped data when you get it from the screen? I think the activity is scraping something that is not typically in an integer.

@rildo13, looking at the screenshot it seems like data
type of varContains is array of string. Hence you are getting error. Please ensure datatype is string and value has only numbers.

1 Like

yes, it is a string. so I want to get the string number value

@rildo13
varContains should be of type String. Please change it from System.String to String in the variables pane and try .

1 Like

varContains is an array of strings. I need to get number 1, and make a condition to perform this task.

Here are the exits.

Can you show us what is in varContains (log each element in the array to the output)? I think we’re close to finding out how to get the value out of the string.

As mentioned above and as you show, you are splitting your captured text by newline which is giving you an array of strings.

Before you can convert to an integer as originally suggested you need to reference the correct index of the array with the string you are wishing to convert.

1 Like

Is the number always the second item in the string array?

If so please use Cint(varContains(1).Trim)

Yes, it always will be.
this error appeared …

@rildo13, You are trying to convert blank value into integer hence you are getting error. Can you please ensure variable has numeric value before calling it in CINT() method?

@rildo13

Before using the Cint please use Int32.TryParse method to check if the value can be parsed to an Int.

If the condition returns true, in the then block add the activity varResult = Cint(varContains(1),Trim)

@rildo13

Hello, this should work for you :point_down:

I don’t have linux, so i didn’t test it, but it works, you have just to check the echo thing…

So, what i did is that, instead of showing just a number i added a variable before it, so that i can find it easly. Than i used regex for find what ever is infront that variable.

Also, since commands sometimes take their time, i added a delay and a loop, so that it loops untel it find the value…

GetResultCMD.zip (7.0 KB)

Let me know how it works for you :slight_smile:

1 Like

I managed to solve friends, I used the (variable) Split (Environment.NewLine.ToArray) and saved it in varContains of type Array.
soon afterwards I used “Cint (varContains (3))” to get the value of number 1 and filed it in varResult.

Thank you all

3 Likes

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