我知道我可以使用一个称为Rnd的准随机数生成函数/变量。 但是,我注意到每当我在用户表单中使用Rnd时,这个数字序列总会显示出来:
第一次迭代:0.705547511577606第二次迭代:0.533424019813538 ...
因此,每当我重新启动用户表单时,b / c显示的数字序列都是相同的,它不会感觉到随机。 VBA功能集中是否还有其他功能会让它感觉更随机? 提前致谢。
I know I can use a quasi-random number generation function/variable called Rnd. However, I've noticed that whenever I used Rnd in my userform, this sequence of numbers always show up:
first iteration: 0.705547511577606 second iteration: 0.533424019813538 ...
As a result, b/c the sequence of numbers showing up are the same every time when I relaunch the userform, it doesn't feel random. Are there other functions in the VBA function set that would make it feel more random? Thanks in advance.
最满意答案
在对Rnd进行任何调用之前,尝试向Randomize Timer添加一个调用。 这将使用一天中的时间播种随机数发生器。
Try adding a single call to Randomize Timer before you do any calls to Rnd. This will seed the random number generator using the time of day.
更多推荐
发布评论