vb 随机生成1个1或2的数
来源:百度知道 编辑:UC知道 时间:2024/06/05 00:55:21
我要用If语句随机输出信息。
你可以使用vb的以下两个函数来完成你的工作。
函数:random函数得到0-1之间的随机数
函数:int()取整就可以了。
dim i as integer
i=Int(2 * Rnd)
if int(100*rnd+1)>50 then
x=1
else
x=2
end if
randomize
if int(Rnd*100) mod 2= 0 then
x=1
else
x=2
end if