vb小游戏源代码 65

编写了石头剪刀布程序后,如果获胜则进行奖励,例如说奖励一只苹果
匿名
 我来答

答题抽奖

首次认真答题后

即可获得3次抽奖机会,100%中奖。

更多问题
推荐于2017-07-08 10:31:40 最佳答案
Dim pFist, cFist, cCount, pCount, dCount, tCount As Integer
Private Sub Form_Load()
cCount = 0
pCount = 0
dCount = 0
tCount = 1
lblPWinNum.Caption = ""
lblPWinNum.Caption = lblPWinNum.Caption & pCount
lblCWinNum.Caption = ""
lblCWinNum.Caption = lblCWinNum.Caption & cCount
lblDrawNum.Caption = ""
lblDrawNum.Caption = lblDrawNum.Caption & dCount
lblTotalNum.Caption = ""
lblTotalNum.Caption = lblTotalNum.Caption & tCount
End Sub
Private Sub imgCloth_Click()
pFist = 3
cFist = Int(Rnd * 3) + 1
txtPlayer.Text = ""
txtPlayer.Text = txtPlayer.Text & "布"
If cFist = 1 Then
txtComputer = ""
txtComputer = txtComputer & "石头"
Else
If cFist = 2 Then
txtComputer = ""
txtComputer = txtComputer & "剪刀"
Else
If cFist = 3 Then
txtComputer = ""
txtComputer = txtComputer & "布"
End If
End If
End If
If cFist = 1 Then
pCount = pCount + 1
lblPWinNum.Caption = ""
lblPWinNum.Caption = lblPWinNum.Caption & pCount
picSusess.Visible = True
MsgBox "恭喜你,你赢了!"
Else
If cFist = 2 Then
cCount = cCount + 1
lblCWinNum.Caption = ""
lblCWinNum.Caption = lblCWinNum.Caption & cCount
MsgBox "很遗憾,你输了!"
Else
dCount = dCount + 1
lblDrawNum.Caption = ""
lblDrawNum.Caption = lblDrawNum.Caption & dCount
MsgBox "打平了!"
End If
End If
tCount = tCount + 1
lblTotalNum.Caption = ""
lblTotalNum.Caption = lblTotalNum.Caption & tCount
End Sub
Private Sub imgScissors_Click()
pFist = 2
cFist = Int(Rnd * 3) + 1
txtPlayer.Text = ""
txtPlayer.Text = txtPlayer.Text & "剪刀"
If cFist = 1 Then
txtComputer = ""
txtComputer = txtComputer & "石头"
Else
If cFist = 2 Then
txtComputer = ""
txtComputer = txtComputer & "剪刀"
Else
If cFist = 3 Then
txtComputer = ""
txtComputer = txtComputer & "布"
End If
End If
End If
If cFist = 3 Then
pCount = pCount + 1
lblPWinNum.Caption = ""
lblPWinNum.Caption = lblPWinNum.Caption & pCount
picSusess.Visible = True
MsgBox "恭喜你,你赢了!"
Else
If cFist = 1 Then
cCount = cCount + 1
lblCWinNum.Caption = ""
lblCWinNum.Caption = lblCWinNum.Caption & cCount
MsgBox "很遗憾,你输了!"
Else
dCount = dCount + 1
lblDrawNum.Caption = ""
lblDrawNum.Caption = lblDrawNum.Caption & dCount
MsgBox "打平了!"
End If
End If
tCount = tCount + 1
lblTotalNum.Caption = ""
lblTotalNum.Caption = lblTotalNum.Caption & tCount
End Sub
Private Sub imgStone_Click()
pFist = 1
cFist = Int(Rnd * 3) + 1
txtPlayer.Text = ""
txtPlayer.Text = txtPlayer.Text & "石头"
If cFist = 1 Then
txtComputer = ""
txtComputer = txtComputer & "石头"
Else
If cFist = 2 Then
txtComputer = ""
txtComputer = txtComputer & "剪刀"
Else
If cFist = 3 Then
txtComputer = ""
txtComputer = txtComputer & "布"
End If
End If
End If
If cFist = 2 Then
pCount = pCount + 1
lblPWinNum.Caption = ""
lblPWinNum.Caption = lblPWinNum.Caption & pCount
picSusess.Visible = True
MsgBox "恭喜你,你赢了!"
Else
If cFist = 3 Then
cCount = cCount + 1
lblCWinNum.Caption = ""
lblCWinNum.Caption = lblCWinNum.Caption & cCount
MsgBox "很遗憾,你输了!"
Else
dCount = dCount + 1
lblDrawNum.Caption = ""
lblDrawNum.Caption = lblDrawNum.Caption & dCount
MsgBox "打平了!"
End If
End If
tCount = tCount + 1
lblTotalNum.Caption = ""
lblTotalNum.Caption = lblTotalNum.Caption & tCount
End Sub
Private Sub picSusess_Click()
picSusess.Visible = False
End Sub
我原来做的一个,按照你的提示加了一个图片,picSusess这个就是图片,里面放着一个苹果的图片,当你赢了就会出现,你点击一下,那个图片就消失,我这个里面除了你这个功能,还有战绩提示,统计你胜负平的局数和第多少局(计算公式是胜负平的局数+1,就是当前局数)

akyu2015

采纳率:61% 来自团队:电脑新手乐园 擅长: 电脑装机/选购

其他回答

Rem 窗体创建三个单选框按钮,Option1、Option2、Option3

Private Sub Form_Activate()
Option1.Caption = "石头"
Option2.Caption = "剪刀"
Option3.Caption = "布"
Option1.Value = False
Option2.Value = False
Option3.Value = False
End Sub

Private Sub Option1_Click()
Randomize
Select Case Int(3 * Rnd)
Case 0: MsgBox "对方也出石头!继续!"
Case 1: MsgBox "哈哈!你赢了!对方出的是剪刀!奖励你一个苹果!"
Case 2: MsgBox "你输了!对方出的是布哦!不好意思,苹果给对方了哈!"
End Select
Option1.Value = False
End Sub

Private Sub Option2_Click()
Randomize
Select Case Int(3 * Rnd)
Case 0: MsgBox "你输了!对方出的是石头哦!不好意思,苹果给对方了哈!"
Case 1: MsgBox "对方也出剪刀!继续!"
Case 2: MsgBox "哈哈!你赢了!对方出的是布!奖励你一个苹果!"
End Select
Option2.Value = False
End Sub

Private Sub Option3_Click()
Randomize
Select Case Int(3 * Rnd)
Case 0: MsgBox "哈哈!你赢了!对方出的是石头!奖励你一个苹果!"
Case 1: MsgBox "你输了!对方出的是剪刀哦!不好意思,苹果给对方了哈!"
Case 2: MsgBox "对方也出布!继续!"
End Select
Option3.Value = False
End Sub
展开
本回答被提问者采纳
玫瑰为你盛开 | 发布于2009-06-02
评论

为您推荐:

广告

您可能关注的内容

×

类别

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

说明

0/200

提交
取消