COLOUR DICE IN VB

To create Dice applicatio ,first of all, you draw a rounded square shape on a form

Secondly, you need to draw an array of 7 dots and VB will automatically labeled them as shape2(0), shape2(1),shape2(2), shape2(3), shape2(4), shape2(5) and shape2(6). You can control the appearance of the dots using the random function RND.

Program:-
Private Sub Command1_Click()
Dim n As Integer
Randomize Timer
n = Int(1 + Rnd * 6)
For i = 0 To 6
Shape2(i).Visible = False
Next
If n = 1 Then
Shape2(3).Visible = True
Shape1.FillColor = &HC0C0C0
End If
If n = 2 Then
Shape2(2).Visible = True
Shape2(4).Visible = True
Shape1.FillColor = &H8080FF
End If
If n = 3 Then
Shape2(2).Visible = True
Shape2(3).Visible = True
Shape2(4).Visible = True
Shape1.FillColor = &H80FF&
End If
If n = 4 Then
Shape2(0).Visible = True
Shape2(2).Visible = True
Shape2(4).Visible = True
Shape2(6).Visible = True
Shape1.FillColor = &HFFFF00
End If
If n = 5 Then
Shape2(0).Visible = True
Shape2(2).Visible = True
Shape2(3).Visible = True
Shape2(4).Visible = True
Shape2(6).Visible = True
Shape1.FillColor = &HFFFF&
End If
If n = 6 Then
Shape2(0).Visible = True
Shape2(1).Visible = True
Shape2(2).Visible = True
Shape2(4).Visible = True
Shape2(5).Visible = True
Shape2(6).Visible = True
Shape1.FillColor = &HFF00FF
End If
End Sub

OUTPUT:-





COLOUR DICE IN VB

To create Dice applicatio ,first of all, you draw a rounded square shape on a form

Secondly, you need to draw an array of 7 dots and VB will automatically labeled them as shape2(0), shape2(1),shape2(2), shape2(3), shape2(4), shape2(5) and shape2(6). You can control the appearance of the dots using the random function RND.

Program:-
Private Sub Command1_Click()
Dim n As Integer
Randomize Timer
n = Int(1 + Rnd * 6)
For i = 0 To 6
Shape2(i).Visible = False
Next
If n = 1 Then
Shape2(3).Visible = True
Shape1.FillColor = &HC0C0C0
End If
If n = 2 Then
Shape2(2).Visible = True
Shape2(4).Visible = True
Shape1.FillColor = &H8080FF
End If
If n = 3 Then
Shape2(2).Visible = True
Shape2(3).Visible = True
Shape2(4).Visible = True
Shape1.FillColor = &H80FF&
End If
If n = 4 Then
Shape2(0).Visible = True
Shape2(2).Visible = True
Shape2(4).Visible = True
Shape2(6).Visible = True
Shape1.FillColor = &HFFFF00
End If
If n = 5 Then
Shape2(0).Visible = True
Shape2(2).Visible = True
Shape2(3).Visible = True
Shape2(4).Visible = True
Shape2(6).Visible = True
Shape1.FillColor = &HFFFF&
End If
If n = 6 Then
Shape2(0).Visible = True
Shape2(1).Visible = True
Shape2(2).Visible = True
Shape2(4).Visible = True
Shape2(5).Visible = True
Shape2(6).Visible = True
Shape1.FillColor = &HFF00FF
End If
End Sub

OUTPUT:-