中易网

帮忙用vb语言编一个剪刀石头布游戏

答案:2  悬赏:50  
解决时间 2021-03-21 14:31
如题,最好写上注释,高手们麻烦快点,我等着交作业,谢谢。
最佳答案
两个LABEL 三个COMMAND 复制代码,就可以了

'-1石头
'0剪刀
'1布
Private Sub Command1_Click()
Dim a, b As Integer
Randomize
a = -1
b = Int(Rnd * (-3) + 2)
Label1.Caption = "石头"
Select Case a - b
Case -2: Label2.Caption = "布": MsgBox "电脑胜"
Case 0: Label2.Caption = "石头": MsgBox "平"
Case -1: Label2.Caption = "剪刀": MsgBox "玩家胜"
End Select

End Sub

Private Sub Command2_Click()
Dim a, b As Integer
Randomize
a = 0
b = Int(Rnd * (-3) + 2)
Label1.Caption = "剪刀"
Select Case a - b
Case 1: Label2.Caption = "布": MsgBox "玩家胜"
Case 0: Label2.Caption = "剪刀": MsgBox "平"
Case -1: Label2.Caption = "石头": MsgBox "电脑胜"
End Select
End Sub

Private Sub Command3_Click()
Dim a, b As Integer
Randomize
a = 1
b = Int(Rnd * (-3) + 2)
Label1.Caption = "布"
Select Case a - b
Case 2: Label2.Caption = "石头": MsgBox "玩家胜"
Case 0: Label2.Caption = "布": MsgBox "平"
Case 1: Label2.Caption = "剪刀": MsgBox "电脑胜"
End Select
End Sub

Private Sub Form_Load()
Command1.Caption = "石头"
Command2.Caption = "剪刀"
Command3.Caption = "布"

End Sub
全部回答

控件,label1上边,label2,command(0-2)下排,command4(0-2) 上排,复制一下代码即可运行

dim myy as integer '我赢得次数 dim myp as integer '平的次数 dim mys as integer '我输的次数,下边是电脑的相同 dim couy as integer dim coup as integer dim cous as integer private sub command1_click(index as integer) dim str as integer

command4(0).visible = false command4(1).visible = false command4(2).visible = false str = int(rnd * 3) command4(str).visible = true if index = 0 then if str = 0 then myp = myp + 1 coup = coup + 1 elseif str = 1 then cous = cous + 1 myy = myy + 1 elseif str = 2 then couy = couy + 1 mys = mys + 1 end if end if if index = 1 then if str = 0 then mys = mys + 1 couy = couy + 1 elseif str = 1 then coup = coup + 1 myp = myp + 1 elseif str = 2 then cous = cous + 1 myy = myy + 1 end if end if if index = 2 then if str = 0 then myy = myy + 1 cous = cous + 1 elseif str = 1 then couy = couy + 1 mys = mys + 1 elseif str = 2 then couy = couy + 1 myy = myy + 1 end if end if label1.caption = "电脑:" & "赢: " & couy & "平: " & coup & "输:" & cous label2.caption = "我:" & "赢: " & myy & "平: " & myp & "输:" & mys end sub

我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
做系统进到75%处就进不去了怎么办
欢乐喜剧人小沈阳是自己一个组的吗?怎么一些
深圳罗湖区湖贝新村邮政编码多少
九下英语阅读盲填
每股净资产和每股市价
广州丛利贸易有限公司的产品如何?
广州师大地铁站到黄村比较快。站
高手进!解决360阻止魔兽世界启动问题!
一个案子
如何调漂 调4目钓2目
从广州番禺客运站去南村岭南电缆厂坐哪路公交
我是河南洛阳农村的想在家养殖兔子,不知道养
oppo手机怎么关相机的人脸识别
鲁迅的作品在大学教材中有哪些?
中国魔术论坛被黑了吗??
推荐资讯
出借人是公务员 到期借款人不还,能否起诉?
家里有那种小飞虫咬人怎么办
石钟乳十万年后,我该是一架大山”前面省略了
南京哪里剪发最好?哪里做头发最好?南京最好的
维修家电vc890c+ 可以吗
七加七除了等于十四,还能等于多少?
急求3-5分钟剧本
重庆市巴南区南泉镇自由村邮编是什么?
v5.5.8版本115云怎么取消手机绑定
请问:东台哪家婚庆公司比较好?
甲男与乙女虽未办理结婚登记,但同居生活,一
请问春天喝什么花茶好.
手机登qq时,显示手机磁盘不足,清理后重新登
刺客的套装怎么选啊?