Support > Forums > OpenBots Studio > Convert string to Int

Convert string to Int

Clara Le Meur

  • Reporter
  • Calender Icon January 31,2022 at 11:42 AM

Hello OpenBots community,

I try to convert a variable string "1234" in a numeric variable but i dont find the right documentation about it. I need to convert it to check if the variable is greater than 0

Does someone have an idea ?

Thanks

This forum has 313 topics, 680 replies, and was last updated 16 days ago by Faheem Syed

Poornima Malviya

  • Participant
  • Calender Icon January 31,2022 at 2:09 PM

Hi, Thankyou for sharing the query. Thankyou for sharing the resolution as well and I hope it will be useful for others. To add up to your resolution -

  1. Set variable command - Use set variable command. We can give Input to make conversion in this way -
    a) Convert.ToInt32(myVariable) or b) Int32.Parse(myVariable) or c) myVariable.ToString()

We can make conversions to either Int64 or Int16 as well by replacing Int32. and output create a number variable and assign it.

Clara Le Meur

  • Participant
  • Calender Icon January 31,2022 at 1:36 PM

Ok I have fund a solution to convert String to Int and in reverse Int to String :

So to convert String to Int :


//String
myVariable = "1234"

//To Int
Int32.Parse(myVariable)

To convert Int to String : Important don't forget the parenthesis : ()


//Int
myVariable = 1234

//To String
myVariable.ToString()

You are not authorized to reply, please click here to login and add your reply to this topic.