Random Number From Variables

Hi, I’m trying to make my first app, a random number picker from a range between two numbers you set on the first page. On the second page I have the following formula. Adding etc works, but random number always returns some number outside of the range. Please help. :slight_smile:


what value is contained in NFrom, NTo and what is returned as a random number?

I’m setting the numbers using input fields and saving them to local storage. I’m not sure if there is an option to save items as integers I’m totally new to this. The random number returns some really random number but not within the range set, for example I set 2 and 5 as the range and it gives me 13, or -43 and similar.


Are you sure that NFrom is the lowest number and NTo the highest ?
Next if it is try puttin the local storage under the other one and not inside and put the label text outside of both but inside screen opens.
Hope it helps.

Funnily enough I am also creating a random number generator and I am also having this problem!

These are my blocks.
My text inputs start with 0 and 100 and if I don’t edit them - they work perfectly.
If I change them, it randomly works, randomly goes wrong

I also tried it the following way with variables:

I got the exact same results

Edit: I also added in an error message if my 2nd number is smaller than my first number.
If I change the first number to 5 and the 2nd to 1000, this error appears :disappointed_relieved:

I think I have it fixed.

Use the Round function to round your inputs before getting a random value and it seems to work.

1 Like

Thank you! This seems to have worked! I would have never figured it out! :smile: :beer: