Number variables are also known as integer or Int32, and are used to store numeric information. They can be used to perform equations or comparisons, pass important data, and many others.
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.
- Create a new sequence.
- Create two Int32 variables,
Age. The first stores the user’s birth year and the second, the user’s age.
- Add an Input Dialog activity to the sequence.
- In the Dialog Title and Input Label fields, type an appropriate title and label.
- In the Value entered field, add the
- Add an Assign activity under the Input Dialog.
- In the Properties panel, in the To field, add the
- In the Value field, type
2022 – BirthYear. This assigns the value of the subtraction (2022 minus the user’s birth year) to the
- Add a Message Box activity under the Assign one.
- In the Properties panel, in the Text field, type "Congratulations! You are " +
.ToStringmethod converts the integer stored in the
Agevariable to a string and displays it as such.
The final project should look as in the following screenshot.
- Press F5. The automation is executed. Note that the Message Box displays your age, as expected.
Updated 3 months ago