石头剪刀布设置VB小游戏代码?
没有图 全用字代替! 很简单。 创建三个command按钮 复制代码 '1石头 '2剪刀 '3布 Private Sub Form_Load() Command1.Caption = “石头”改变每个按钮的名称 Command2.Caption = "剪刀" Command3.Caption = "布" End Sub Private Sub command1_Click() '石头 Dim CPU As Integer Dim a As String CPU = Int(Rnd * 3) + 1 “RND生成” 大于0 小于1 之间的随机数 ,这里是生成1-3的随机数 If CPU = 1 Then a = “石头,平局” If CPU = 2 Then a = “剪刀,玩家赢” If CPU = 3 Then a = “布,电脑赢” MsgBox “玩家出石头,电脑出" & a End Sub Private Sub command2_Click() '剪刀 Dim CPU As Integer Dim a As String CPU = Int(Rnd * 3) + 1 If CPU = 1 Then a = "石头,电脑赢" If CPU = 2 Then a = “剪刀,平局” If CPU = 3 Then a = “布,玩家赢” MsgBox "玩家出剪刀,电脑出" & a End Sub Private Sub command3_Click() '布 Dim CPU As Integer Dim a As String CPU = Int(Rnd * 3) + 1 If CPU = 1 Then a = "石头,玩家赢" If CPU = 2 Then a = “剪刀,电脑赢” If CPU = 3 Then a = “布,平局” MsgBox “玩家出版,电脑出版” & a End Sub