The How-To Geek Forums Have Migrated to Discourse

How-To Geek Forums / Geek Stuff

RND() question

(2 posts)
  • Started 4 years ago by GBJIMANDREWS
  • Latest reply from raphoenix
  • Topic Viewed 266 times

Posts: 1

Back in the day of peeks, pokes and calls in BASIC, there was a seed location for the rnd() function.

Went something like this:
poke(XX1) 1
poke(XX2) 1
poke(XX3) 1
poke(XX4) 1
poke(XX5) 1

This put the value 1 into those locations, then
would return an integer value between 0 and 255, say, 92.
another int(rnd(0;255)) would return 219, and a third int(rnd(0;255)) would return 47.

Poking 1s into those locations again and another 3 calls to int(rnd(0;255)) would produce the same series of 'random' numbers; 92, 219 and 47.

Does anyone know of a similar situation where the rnd() return will be predictable?
I have just retired and have always wanted to complete an encryption proggy with this as the core, but have progressed to C++, VB and C#.

Thanks in advance,

Edit Email addresses are not allowed in posts. All answers will be provided here in this topic. -- GModX

Posted 4 years ago
Posts: 14920

In VB, to repeat a sequences of random numbers, call Rnd with a negative argument immediately before using Randomize with a numeric argument.

We have Two Members who really know plus practice VB and Scripting so may be they will answer also.

Posted 4 years ago

Topic Closed

This topic has been closed to new replies.