studio
2020.10
false
OUT OF SUPPORT
Studio User Guide
Last updated Dec 20, 2023

Example of Using a Number Variable

To exemplify how you can work with number variables, we are going to create an automation that asks the user for the year in which he or she was born and displays the age in a window.

  1. Create a new sequence.
  2. Create two Int32 variables, BirthYear and Age. The first stores the user’s birth year and the second, the user’s age.
  3. Add an Input Dialog activity to the sequence.
  4. In the Properties window, type an appropriate title and label.
  5. In the Result field, add the BirthYear variable.
  6. Add an Assign activity under the Input Dialog.
  7. In the Properties panel, in the To field, add the Age variable.
  8. In the Value field, type 2019 – BirthYear. This assigns the value of the subtraction (2019 minus the user’s birth year) to the Age variable.
  9. Add a Message Box activity under the Assign one.
  10. In the Properties panel, in the Text field, type "Congratulations! You are " + Age.ToString + ".".
    Note: The .ToString method converts the integer stored in the Age variable to a string and displays it as such.

The final project should look as in the following screenshot.



11. Press F5. The automation is executed. Note that the Message Box displays your age, as expected.



Was this page helpful?

Get The Help You Need
Learning RPA - Automation Courses
UiPath Community Forum
Uipath Logo White
Trust and Security
© 2005-2024 UiPath. All rights reserved.