'Vb2008EE Public Class Form1 Const sikoro_suu As Integer = 3 Dim sikoro(sikoro_suu - 1) As Integer Dim sikoroRandom As System.Random Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Me.BackColor = Color.Green Me.Size = New Size(300, 300) Button1.Location = New Point(190, 20) Button1.Text = "Start" Button2.Location = New Point(190, 50) Button2.Text = "Stop" PictureBox1.Location = New Point(10, 10) PictureBox1.BackColor = Color.Gray PictureBox1.Size = New Size(265, 245) sikoroRandom = New System.Random() Timer1.Interval = 70 sikoro(0) = 1 : sikoro(1) = 1 : sikoro(2) = 1 End Sub Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint Dim g As Graphics = e.Graphics g.SmoothingMode = Drawing2D.SmoothingMode.HighQuality For i As Integer = 0 To 2 g.FillRectangle(Brushes.White, 20 + i * 100, 20 + i * 90, 30, 30) Select Case sikoro(i) Case 1 'ダイス目__1 g.FillEllipse(Brushes.Red, 26 + i * 100, 26 + i * 90, 18, 18) Case 2 'ダイス目__2 g.FillEllipse(Brushes.Black, 23 + i * 100, 23 + i * 90, 10, 10) g.FillEllipse(Brushes.Black, 37 + i * 100, 37 + i * 90, 10, 10) Case 3 'ダイス目__3 For z As Integer = 0 To 2 g.FillEllipse(Brushes.Blue, (40 - (9 * z)) + i * 100, 23 + (8 * z) + i * 90, 8, 8) Next End Select Next End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick For i As Integer = 0 To 2 sikoro(i) = sikoroRandom.Next(1, 4) Next PictureBox1.Invalidate() End Sub Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Timer1.Start() End Sub Private Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click Timer1.Stop() End Sub End Class