VB 程序编写石头剪刀布小游戏 求高手帮忙 5
我希望用X,Y,Z来实现计数,X记录电脑胜利次数,Y记录“你”胜利次数,Z记录总共进行多少次游戏。所有代码如下,如果不计数的话,删除所有与X,Y,Z相关的行就能正常运行,...
我希望用 X,Y,Z 来实现计数,X记录电脑胜利次数,Y记录“你”胜利次数,Z记录总共进行多少次游戏。
所有代码如下, 如果不计数的话,删除所有与X,Y,Z相关的行就能正常运行,但是我希望能够计数。请大神帮我补充修改正确。
Private Sub Command1_Click()
Dim a As Integer
z = z + 1
a = Int(Rnd * 10) Mod 3
Picture2.Picture = LoadPicture("E:\test\21.JPG")
If a = 0 Then
Picture1.Picture = LoadPicture("E:\test\11.JPG")
MsgBox ("你们平手")
ElseIf a = 1 Then
Picture1.Picture = LoadPicture("E:\test\12.JPG")
MsgBox ("你胜利了")
y = y + 1
Else
Picture1.Picture = LoadPicture("E:\test\13.JPG")
MsgBox ("电脑胜利")
x = x + 1
End If
Text1.Text = ("电脑胜利 ") & x&(" 盘")
Text2.Text = ("你胜利 ") & y&(" 盘")
End Sub
Private Sub Command2_Click()
Dim a As Integer
z = z + 1
a = Int(Rnd * 10) Mod 3
Picture2.Picture = LoadPicture("E:\test\22.JPG")
If a = 0 Then
Picture1.Picture = LoadPicture("E:\test\11.JPG")
MsgBox ("电脑胜利")
x = x + 1
ElseIf a = 1 Then
Picture1.Picture = LoadPicture("E:\test\12.JPG")
MsgBox ("你们平手")
Else
Picture1.Picture = LoadPicture("E:\test\13.JPG")
MsgBox ("你胜利了")
y = y + 1
End If
Text1.Text = ("电脑胜利 ") & x&(" 盘")
Text2.Text = ("你胜利 ") & y&(" 盘")
End Sub
Private Sub Command3_Click()
Dim a As Integer
z = z + 1
Picture2.Picture = LoadPicture("E:\test\23.JPG")
a = Int(Rnd * 10) Mod 3
If a = 0 Then
Picture1.Picture = LoadPicture("E:\test\11.JPG")
MsgBox ("你胜利了")
y = y + 1
ElseIf a = 1 Then
Picture1.Picture = LoadPicture("E:\test\12.JPG")
MsgBox ("电脑胜利")
x = x + 1
Else
Picture1.Picture = LoadPicture("E:\test\13.JPG")
MsgBox ("你们平手")
End If
Text1.Text = ("电脑胜利 ") & x&(" 盘")
Text2.Text = ("你胜利 ") & y&(" 盘")
End Sub 展开
所有代码如下, 如果不计数的话,删除所有与X,Y,Z相关的行就能正常运行,但是我希望能够计数。请大神帮我补充修改正确。
Private Sub Command1_Click()
Dim a As Integer
z = z + 1
a = Int(Rnd * 10) Mod 3
Picture2.Picture = LoadPicture("E:\test\21.JPG")
If a = 0 Then
Picture1.Picture = LoadPicture("E:\test\11.JPG")
MsgBox ("你们平手")
ElseIf a = 1 Then
Picture1.Picture = LoadPicture("E:\test\12.JPG")
MsgBox ("你胜利了")
y = y + 1
Else
Picture1.Picture = LoadPicture("E:\test\13.JPG")
MsgBox ("电脑胜利")
x = x + 1
End If
Text1.Text = ("电脑胜利 ") & x&(" 盘")
Text2.Text = ("你胜利 ") & y&(" 盘")
End Sub
Private Sub Command2_Click()
Dim a As Integer
z = z + 1
a = Int(Rnd * 10) Mod 3
Picture2.Picture = LoadPicture("E:\test\22.JPG")
If a = 0 Then
Picture1.Picture = LoadPicture("E:\test\11.JPG")
MsgBox ("电脑胜利")
x = x + 1
ElseIf a = 1 Then
Picture1.Picture = LoadPicture("E:\test\12.JPG")
MsgBox ("你们平手")
Else
Picture1.Picture = LoadPicture("E:\test\13.JPG")
MsgBox ("你胜利了")
y = y + 1
End If
Text1.Text = ("电脑胜利 ") & x&(" 盘")
Text2.Text = ("你胜利 ") & y&(" 盘")
End Sub
Private Sub Command3_Click()
Dim a As Integer
z = z + 1
Picture2.Picture = LoadPicture("E:\test\23.JPG")
a = Int(Rnd * 10) Mod 3
If a = 0 Then
Picture1.Picture = LoadPicture("E:\test\11.JPG")
MsgBox ("你胜利了")
y = y + 1
ElseIf a = 1 Then
Picture1.Picture = LoadPicture("E:\test\12.JPG")
MsgBox ("电脑胜利")
x = x + 1
Else
Picture1.Picture = LoadPicture("E:\test\13.JPG")
MsgBox ("你们平手")
End If
Text1.Text = ("电脑胜利 ") & x&(" 盘")
Text2.Text = ("你胜利 ") & y&(" 盘")
End Sub 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励10(财富值+成长值)+提问者悬赏5(财富值+成长值)
1个回答
展开全部
在代码页的最前面加入以下的2行:
Option Base 1
Dim x As Integer, y As Integer, z As Integer
另外,所有的以下部分要修改:
Text1.Text = ("电脑胜利 ") & x&(" 盘")
Text2.Text = ("你胜利 ") & y&(" 盘")
改为:
Text1.Text = "电脑胜利 " & x & " 盘"
Text2.Text = "你胜利 " & y & " 盘"
Option Base 1
Dim x As Integer, y As Integer, z As Integer
另外,所有的以下部分要修改:
Text1.Text = ("电脑胜利 ") & x&(" 盘")
Text2.Text = ("你胜利 ") & y&(" 盘")
改为:
Text1.Text = "电脑胜利 " & x & " 盘"
Text2.Text = "你胜利 " & y & " 盘"
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询