永发信息网

用VB编一个与电脑玩石头剪刀布的游戏

答案:3  悬赏:10  手机版
解决时间 2021-04-30 01:09
  • 提问者网友:世勋超人
  • 2021-04-29 05:23
如题,越简单越好
最佳答案
  • 五星知识达人网友:舍身薄凉客
  • 2021-04-29 06:56


控件,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

全部回答
  • 1楼网友:鱼芗
  • 2021-04-29 07:40
那电脑可以100%赢你
  • 2楼网友:煞尾
  • 2021-04-29 07:16

- -

- 不难嘛~ 和Javai差不多 产生3個随机数 然后对比

我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯