VB6.0随机变量

来源:百度知道 编辑:UC知道 时间:2024/06/25 00:31:25
我在做个个猜猜看的一个程序,(纯属个人娱乐,低B不要见怪)
建立了个Label1,还有2个Command(Command2,Command3)为猜键,
一个Command(Command1)为开始键

当点击Command1时,label1就随机产生了个
Int(Rnd * (90 - 65 + 1) + 65)数字
问:
我现在要在Command2,Command3中随机藏在这里之间,
如何输入语句?
是if语句吗?
是把Label1中的所产生的随机字母藏在Command2,Command3中,点中了就显示Label1的随机字母,错了就弹出错误提示窗口

补充2:
不是啊!是在Label1中所产生的字母藏在在Command2或Command3中给你猜

是不是猜大猜小啊 你判断一下不就可以了!!比如说
command2 的click里面你可以这么写
Private Sub Command2_Click()
call Command2_Click
if val(label1.caption)>yournumber then
label1.caption=label1.caption+" 你真利害猜对了!!"
else
label1.caption=label1.caption+" 对不起你猜错了了!!"
End Sub
command内也同理处理只不过是在大于号换为小于号
command1的代码应该为:
Private Sub Command1_Click()
label1.caption=cstr(Int(Rnd * (90 - 65 + 1) + 65))
End Sub