[thelist] Random Numbers in ASP
Duncan O'Neill
dbaxo at ihug.co.nz
Thu Jul 25 17:05:01 CDT 2002
Ken Kogler wrote:
> I want to write a function that takes a number as a parameter, and returns a
> random number between 1 and whatever number it was given.
>
> I'm having trouble with this... anyone care to take a stab at it?
>
> Thanks in advance, evoltans!
>
> --ken
>
Ken,
here's my stab --
if input is 10 it should return any
number in the range 1 to 9. No doubt
there are more elegant ways of doing
this, but this should work.
Function getRandom(input)
Randomize
getRandom = Int(Rnd*(input-1)) + 1
END FUNCTION
hth
--
=====================================================
Duncan O'Neill
"Smith The Reporter"
http://homepages.ihug.co.nz/~dbaxo/urban_legend.htm
=====================================================
More information about the thelist
mailing list