Support > Forums > OpenBots Studio > Convert string to Int

Convert string to Int

Lakshmi S

  • 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 173 topics, 516 replies, and was last updated 10 months ago by Ehtesham Abad

  • Participant
  • Calender Icon July 27,2022 at 7:58 PM

TopicDetailModel.Answer.Content

Lakshmi S

  • 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.

Lakshmi S

  • 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.