小程序 猜石头剪刀布

时间:2014-03-30 08:11:56
【文件属性】:

文件名称:小程序 猜石头剪刀布

文件大小:2KB

文件格式:TXT

更新时间:2014-03-30 08:11:56

石头剪刀布

石头剪刀布的源代码我也是新手,随便做个玩玩。把RadioButton0,1,2放一个容器里! Public Class Form1 Dim win1 As Integer = 0 Dim win2 As Integer = 0 Dim i As Integer Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim str As Integer Dim rand As New Random() str =rand.Next(3)'随机数 If str = 0 Then RadioButton0.Checked = True ElseIf str = 1 Then RadioButton1.Checked = True ElseIf str = 2 Then RadioButton2.Checked = True End If If RadioButton3.Checked = True Then i = 0 ElseIf RadioButton4.Checked = True Then i = 1 ElseIf RadioButton5.Checked = True Then i = 2 Else MsgBox("请选择要出的拳法!") End If If (str = 0 And i = 1) Or (str = 1 And i = 2) Or (str = 2 And i = 0) Then win1 += 1 TextBox1.Text = "玩家胜利" ElseIf (str = 0 And i = 2) Or (str = 1 And i = 0) Or (str = 2 And i = 1) Then win2 += 1 TextBox1.Text = "电脑胜利" Else TextBox1.Text = "平手" End If'判断胜利者 TextBox2.Text = win1 TextBox3.Text = win2 If win1 = 5 Then MsgBox("最终胜利者是玩家!恭喜!") win1 = 0 win2 = 0 For i = 0 To Me.Controls.Count - 1 If TypeOf (Me.Controls(i)) Is TextBox Then Me.Controls(i).Text = "" End If'清空过时信息 Next ElseIf win2 = 5 Then MsgBox("最终胜利者是电脑!") win1 = 0 win2 = 0 For i = 0 To Me.Controls.Count - 1 If TypeOf (Me.Controls(i)) Is TextBox Then Me.Controls(i).Text = "" End If'清空过时信息 Next End If End Sub End Class


网友评论

  • 逻辑性很强的小游戏