VB小游戏石头剪刀布设置代码?

1分钟前阅读2回复0
zaibaike
zaibaike
  • 管理员
  • 注册排名1
  • 经验值632880
  • 级别管理员
  • 主题126576
  • 回复0
楼主

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

0
回帖 返回游戏电竞

VB小游戏石头剪刀布设置代码? 期待您的回复!

取消