1 / 7

VBAを使ったゲーム ジャンケンゲーム

VBAを使ったゲーム ジャンケンゲーム. ___高校 1 年 組  番 _____. プレゼンテーション内容. ジャンケンゲーム 作り方 詳しい説明. ジャンケンゲーム. 作り方. セル( 10 , 4 )に、 0 , 1 , 2 の内 どれかを乱数で発生させます。. パーの出し方についての説明 Sub pa() Cells(10, 4) = Int(Rnd * 3) Cells(10, 10) = 2 If Cells(10, 10) = 2 Then Cells(10, 9) = " パー "

coty
Télécharger la présentation

VBAを使ったゲーム ジャンケンゲーム

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. VBAを使ったゲームジャンケンゲーム ___高校1年 組  番 _____

  2. プレゼンテーション内容 • ジャンケンゲーム • 作り方 • 詳しい説明

  3. ジャンケンゲーム

  4. 作り方 セル(10,4)に、0,1,2の内 どれかを乱数で発生させます。 • パーの出し方についての説明 • Sub pa() • Cells(10, 4) = Int(Rnd * 3) • Cells(10, 10) = 2 • If Cells(10, 10) = 2 Then • Cells(10, 9) = "パー" • End If • If Cells(10, 4) = 0 Then • Cells(10, 5) = “グー”    • ElseIf Cells(10, 4) = 1 Then • Cells(10, 5) = "チョキ" • ElseIf Cells(10, 4) = 2 Then • Cells(10, 5) = "パー" • End If セル(10,10)に2を表示させ、 セル(10,9)に“パー”と表示させます。 セル(10,4)に発生した乱数が0なら、 セル(10,5)に“グー”と表示させ、同じように 1ならチョキ、2ならパーと出るようにします。

  5. 作り方2 セル(10,4)に書いてある数字から、 セル(10,10)に書いてある数字を引きます。 • If Cells(10, 4) - Cells(10, 10) = -1 Then • MsgBox "あなたの負けです" • ElseIf Cells(10, 4) - Cells(10, 10) = -2 Then • MsgBox "あなたの勝ちです" • ElseIf Cells(10, 4) - Cells(10, 10) = 2 Then • MsgBox "あなたの負けです" • ElseIf Cells(10, 4) - Cells(10, 10) = 1 Then • MsgBox "あなたの勝ちです" • ElseIf Cells(10, 4) - Cells(10, 10) = 0 Then • MsgBox "あいこです" • End If • End Sub 引いた数字が-2の時、 メッセージボックスに “あなたの勝ちです”と表示させます。 同じように進めていき、 最後に引いた数字が0時、 それぞれ手は同じということになるので “あいこです”と表示させます。

  6. 詳しい説明(簡単な説明) 1 0 勝敗の出し方 PCのセル(この場合0)と、プレイヤーのセル(この場合1)を引き算します。 例* 0(PCがグー)-1(プレイヤーがチョキ)=-1 →メッセージボックス”あなたの負けです” 他の引き算、{例えば1(チョキ)-2(パー)}の場合も同じように使うことが出来ます。

  7. 終わり

More Related