Question: I have a textbox `Job` in `Form2`, and I have multiple textboxes in `Form1`.

Lets say in `form1` I have `Textbox1` which is `RollFromInventory`, `Textbox2` is `RollFromMachine1`, `Texbox3` is `RollFromMachine2` and so on, assume there are 4 other machines, so four other Textboxes. 

When I want to populate the textbox `Job` in `Form2`, I want to write an `If` loop which should look for the textbox which has value populated in it, in `form1` (there will be only one textbox which will have a value among all the available textboxes in `form1`), i.e. either `RollFromInventory` will have a value or `RollFromMachine1` will have a value or `RollFromMachine2`.. 

I am unsure of the looping logic, so I cant really figure out how to go about it.

Currently the code I have written is mainly for populating concatenated values (I am not providing that code, because it will make the objective seem complicated).

Answer: 
This should work:

```
def validate(num):
    try:
        n = int(num)
        return 2 <= n <= 4094
    except:
        return False

```

The above function returns `True` if the number is an integer in the specified range, `False` otherwise.
When the function below return True, you can do the Math you need to do with the number.

```
def as_int_in_range(value,range):
    try:
        value = int(value)
        if value >= range[0] and value <= range[1]:
            return True,value 
        else:
            return False,None 
    except ValueError:
        return False,None

is_int,val = as_int_in_range('12',(10,100))
if is_int:
    # do something with 'val' assuming it is int in the range
else:
    # do something  else        

```