Develop Dice game in VB.NET I Scheme Micro Project

GUI:

Code:


Public Class Form1

    Dim Dice1 As Integer
    Dim Dice2 As Integer
    Dim Random As Random

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Timer1.Start()


    End Sub

    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        Random = New Random
        ProgressBar1.Increment(10)

        If ProgressBar1.Value = 100 Then
            Timer1.Stop()
            ProgressBar1.Value = 0
        Else

            Dice1 = Random.Next(1, 6)
            Dice2 = Random.Next(1, 6)
            'Dice 2

            If Dice1 = 1 Then
                PictureBox1.Image = My.Resources.dice_rolling_1
            ElseIf Dice1 = 2 Then
                PictureBox1.Image = My.Resources.dice_rolling_2
            ElseIf Dice1 = 3 Then
                PictureBox1.Image = My.Resources.dice_rolling_3
            ElseIf Dice1 = 4 Then
                PictureBox1.Image = My.Resources.dice_rolling_4
            ElseIf Dice1 = 5 Then
                PictureBox1.Image = My.Resources.dice_rolling_5
            ElseIf Dice1 = 6 Then
                PictureBox1.Image = My.Resources.dice_rolling_6
            End If

            'Dice 2

            If Dice2 = 1 Then
                PictureBox2.Image = My.Resources.dice_rolling_1
            ElseIf Dice2 = 2 Then
                PictureBox2.Image = My.Resources.dice_rolling_2
            ElseIf Dice2 = 3 Then
                PictureBox2.Image = My.Resources.dice_rolling_3
            ElseIf Dice2 = 4 Then
                PictureBox2.Image = My.Resources.dice_rolling_4
            ElseIf Dice2 = 5 Then
                PictureBox2.Image = My.Resources.dice_rolling_5
            ElseIf Dice2 = 6 Then
                PictureBox2.Image = My.Resources.dice_rolling_6
            End If
        End If

    End Sub


End Class


Output:
















Comments