Use the “Input Dialog” activity to prompt the user to enter a number. Store the result in a string variable, let’s call it “inputNumber”.
Use the “Try Catch” activity to wrap the logic that attempts to convert the input string to an integer.
In the “Try” section, use the “Int32.Parse” method to convert the input string to an integer. Store the result in an integer variable, let’s call it “parsedNumber”.
In the “Catch” section, use the “Message Box” activity to display an error message to the user.
Here’s an example of the complete UiPath workflow:
# Step 1
inputNumber = InputDialog("Enter a number:")
# Step 2
Try
# Step 3
parsedNumber = Int32.Parse(inputNumber)
Catch
# Step 4
MessageBox("This is not a number. Try again")
End Try