'サイコロ三つでスロット?ポーカー? by Y.Arai 'PictureBoxが9個、Labelが3つ必要 '予めサイコロの絵6つ(dice-1.PNGなど)を、このプロジェクトのbinフォルダ下に置いておく Dim d1, d2, d3 Dim i, j Randomize() '予め全てのサイコロの絵を、PictureBox1〜6に読み込んでおく PictureBox1.Image = Image.FromFile("dice-1.PNG") PictureBox2.Image = Image.FromFile("dice-2.PNG") PictureBox3.Image = Image.FromFile("dice-3.PNG") PictureBox4.Image = Image.FromFile("dice-4.PNG") PictureBox5.Image = Image.FromFile("dice-5.PNG") PictureBox6.Image = Image.FromFile("dice-6.PNG") 'サイコロの絵を切り替えてコロコロ感を出す 'サイコロ3つはそれぞれPictureBox7,8,9に表示するものとする 'サイコロ三つを20回振り最初の19回はコロコロ感を出すためとし、 '最後の1回が本番とする For i = 0 To 20 d1 = Int(Rnd(1) * 6 + 1) d2 = Int(Rnd(1) * 6 + 1) d3 = Int(Rnd(1) * 6 + 1) Select Case d1 Case 1 PictureBox7.Image = PictureBox1.Image Case 2 PictureBox7.Image = PictureBox2.Image Case 3 PictureBox7.Image = PictureBox3.Image Case 4 PictureBox7.Image = PictureBox4.Image Case 5 PictureBox7.Image = PictureBox5.Image Case 6 PictureBox7.Image = PictureBox6.Image End Select '2番目のサイコロの表示→PictureBox8 Select Case d2 Case 1 PictureBox8.Image = PictureBox1.Image Case 2 PictureBox8.Image = PictureBox2.Image Case 3 PictureBox8.Image = PictureBox3.Image Case 4 PictureBox8.Image = PictureBox4.Image Case 5 PictureBox8.Image = PictureBox5.Image Case 6 PictureBox8.Image = PictureBox6.Image End Select '3番目のサイコロの表示→PictureBox9 Select Case d3 Case 1 PictureBox9.Image = PictureBox1.Image Case 2 PictureBox9.Image = PictureBox2.Image Case 3 PictureBox9.Image = PictureBox3.Image Case 4 PictureBox9.Image = PictureBox4.Image Case 5 PictureBox9.Image = PictureBox5.Image Case 6 PictureBox9.Image = PictureBox6.Image End Select '絵をきちんと表示するためのおまじない PictureBox7.Refresh() PictureBox8.Refresh() PictureBox9.Refresh() '早く切り替わりすぎて分からなくならないように、空のFor文でちょっと待つ For j = 0 To 100000 Next j Next i 'Labelに3つのサイコロの数字を表示 Label1.Text = d1 Label2.Text = d2 Label3.Text = d3 '役の判定 'まずペアがあるかないかを判断 If d1 = d2 Or d2 = d3 Or d3 = d1 Then 'ペアがある場合、三つの目が同じだったらスリーカード If d1 = d2 And d2 = d3 Then Label4.Text = "スリーカード" Else Label4.Text = "ワンペアー" End If Else Label4.Text = "ぶた" End If