Wow, great and very helpfull solution. Thanks
Wow, great and very helpfull solution. Thanks
Val(Mid$(Left$("01020304050607080910", (value( "Counter" )-1)*2)+Right$("01020304050607080910", 20-(value( "Counter" )*2)), Random(9)*2, 2))
Can... someone break down what this fearsome line is doing? It's beyond me at this time in the afternoon![]()
It took me a while to get,
but I really like this kind of things so it was well worth
let's disregard "val",
then we have:
Mid$(*string*, Random(9)*2,2)
*string* is composed by:
Left$("01020304050607080910",(value("Counter")-1)*2)
will return the left part before counter value
(i.e. counter=6, will return "0102030405")
+ Right$ ("01020304050607080910", 20-(value( "Counter" )*2))
will return the right part after counter value
(i.e. counter=6, will return "07080910")
so we have a full pool of numbers excluding the counter value
(i.e. counter=6, string=010203040507080910)
Now the Mid function will return a even pair of strings from Random(9)*2,
thus giving a random number excluding the counter value.
Beautiful and clever!
Maybe also a little tricky to write down, I can guess![]()
Fun, but don't overlook Tendro's solution - it's by far the most dynamic:
Set Counter to ( ( value( "Counter" ) + Random(9 ) ) mod 10 ) + 1
Agreed,
that's the easier/quicker to setup, and a little more clean to inspect.
But I'd give both a trophy for brainiest solution![]()
this should work:
(( value( "Counter" ) + 1 + Random(8 ) ) mod 9 ) + 1
Hi,
No it's not working very well because i need numbers between 1-9, but when i use +1 then number 9 + 1 = 10.
Have you tested it?
It's not just final +1 but also changed the random(n) and mod(n)
There is a windows only extension called Random Number Pool although I've not used it for years. It might do what you wanted too.