Try catch box

am creating a Dialog box which should accept only Integers as input, so I created the output of Dialog Box as int32 so that it cannot accept any string value when we enter some Alphabetic characters or Special Characters it will throw an error because of that I kept the Dialog box in the Try catch block, so that when you enter the value another than number it will throw the error in Try block that will be caught by Catch Block. In the catch block, I declared a Variable which stores the value of exception, and then I placed this Try catch in a while loop with condition Variable <> " "When ever the exception variable is not empty it should iterate the loop if not it should allow the process to run, but when I enter the wrong value for the first time it is getting iterated, but when I enter the correct value for the second time it is throwing the error, could you please resolve this.
Dialog Box.xaml (8.6 KB)

  1. When you enter a numeric value less than the required nine digits, the first while condition is met as it is numeric, but it fails on the second. However, it gets stuck in a while loop because you have not recounted the length of the new input. The condition is still looking at the original value of NoofDigits which will evaluate as True.

  2. Same with the first. You are looping on the condition of “Exception” being populated. So as soon as it has been assigned a value once, you are stuck in the loop. You should reset your exception to Null each time it loops back.

See attached.

Dialog Box.xaml (11.0 KB)

Once you take the input from user try to check if the input is integer or not by loop may be, while loop would be best idea, and if the input is int then break or else increment the counter for number of tries and then ask the user to enter the input again, until the max try reaches.

Let us know if this helps,
Pavan H