vba更真实的随机数发生器(vba more realistic random number generator)

编程入门 行业动态 更新时间:2024-10-28 08:26:34
vba更真实的随机数发生器(vba more realistic random number generator)

我知道我可以使用一个称为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.

更多推荐

本文发布于:2023-08-03 13:42:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1392477.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:随机数   发生器   真实   vba   generator

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!