以下是VBA产生随机整数的代码示例:

'产生1到10之间的随机整数
Randomize
Dim randomInt As Integer
randomInt = Int((10 - 1 + 1) * Rnd + 1)
MsgBox randomInt

解释:

  • Randomize:初始化随机数生成器。
  • Int((10 - 1 + 1) * Rnd + 1):计算1到10之间的随机整数。其中,Rnd函数返回0到1之间的随机数。
  • MsgBox:显示随机整数的值。
vba 产生随机整数

原文地址: https://www.cveoy.top/t/topic/cIBZ 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录