2个回答
展开全部
两个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
'-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
展开全部
Private Sub Command1_Click()
a = 1 '石头
Call fight(a)
End Sub
Private Sub Command2_Click()
a = 2 '剪刀
Call fight(a)
End Sub
屏幕上添加3个command
Private Sub Command3_Click()
a = 3 '布
Call fight(a)
End Sub
Private Sub Form_Load()
End Sub
Public Sub fight(a)
Randomize
b = Int(Rnd * 3 + 1)
Select Case a
Case 1
Select Case b
Case 1
MsgBox ("平")
Case 2
MsgBox ("胜")
Case 3
MsgBox ("输")
End Select
Case 2
Select Case b
Case 1
MsgBox ("输")
Case 2
MsgBox ("平")
Case 3
MsgBox ("胜")
End Select
Case 3
Select Case b
Case 1
MsgBox ("胜")
Case 2
MsgBox ("输")
Case 3
MsgBox ("平")
End Select
End Select
End Sub
a = 1 '石头
Call fight(a)
End Sub
Private Sub Command2_Click()
a = 2 '剪刀
Call fight(a)
End Sub
屏幕上添加3个command
Private Sub Command3_Click()
a = 3 '布
Call fight(a)
End Sub
Private Sub Form_Load()
End Sub
Public Sub fight(a)
Randomize
b = Int(Rnd * 3 + 1)
Select Case a
Case 1
Select Case b
Case 1
MsgBox ("平")
Case 2
MsgBox ("胜")
Case 3
MsgBox ("输")
End Select
Case 2
Select Case b
Case 1
MsgBox ("输")
Case 2
MsgBox ("平")
Case 3
MsgBox ("胜")
End Select
Case 3
Select Case b
Case 1
MsgBox ("胜")
Case 2
MsgBox ("输")
Case 3
MsgBox ("平")
End Select
End Select
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询