當前位置:編程學習大全網 - 編程軟體 - 怎麽用VB編壹個猜拳遊戲?

怎麽用VB編壹個猜拳遊戲?

Private Sub Command1_Click()

Cls

If Option1.Value = True Then user = 1

If Option2.Value = True Then user = 2

If Option2.Value = True Then user = 3

Randomize Timer

computer = Int(Rnd * 3 + 1)

If computer = 1 Then Label3.Caption = "剪刀"

If computer = 2 Then Label3.Caption = "石頭"

If computer = 3 Then Label3.Caption = "布"

a = user - computer

If a = 0 Then Print "平"

If a = -1 Or a = 2 Then Print "輸"

If a = 1 Or a = -2 Then Print "贏"

End Sub

Private Sub Form_Load()

Label1.Caption = "User"

Label2.Caption = "Computer"

Option1.Caption = "剪刀"

Option2.Caption = "石頭"

Option3.Caption = "布"

End Sub

  • 上一篇:電視屏幕沒有投影功能怎麽投影?
  • 下一篇:JAVA輸入長和寬打印實心矩形。要簡單點的方法。打印結果大概是 ****** ****** ******
  • copyright 2024編程學習大全網