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

如题,最好写上注释,高手们麻烦快点,我等着交作业,谢谢。... 如题,最好写上注释,高手们麻烦快点,我等着交作业,谢谢。 展开
 我来答
aa4681464
2009-11-14 · TA获得超过1138个赞
知道小有建树答主
回答量:922
采纳率:0%
帮助的人:828万
展开全部
两个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
tq5124
2009-11-14 · 超过46用户采纳过TA的回答
知道小有建树答主
回答量:115
采纳率:0%
帮助的人:123万
展开全部
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
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式