Selecting a random number using the result of a previous numeric question

Hi Colleagues:
I have a question, Number of Dwellings with a variable name Ndwell. Following this question I want to randomly select a number between 1 to the value entered in the previous question (Ndwell). Since I do not know C# I am trying to adapt this code to generate the result I want but it is not working. Any help will be appreciated:

(int)Math.Round((Ndwell-0)*Quest.IRnd() + 1)

Best Regards
Edwin

Sorry, I think I got it using (int)Math.Round((Ndwell.Value-1)*Quest.IRnd() + 1)

(int)Math.Floor(Quest.IRnd()*Ndwell.Value+1)