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.
PROCEDURE:-
1. Create a new project in VB 6.0, Draw four lines on the form as shown in the figure.
2. Place an Image control on the form, copy it and paste for 8 times (Image Control Array).
3. Now again place Image2, Image3 on the form and add Cross picture and Circle picture for player-1 and player-2 respectively.
4. Place two labels and change the caption as Player-1 and Player-2.
5.Place two command buttons and change their caption property as Play Again and Exit respectively.
Design View:-
PROGRAM CODE:-
Dim cross(8) As Boolean
Dim ball(8) As Boolean
Dim m As Integer
Dim player As Integer
Sub check_status()
If ball(0) = True And ball(1) = True And ball(2) = True Then
MsgBox "Player-1 Wins"
End If
If ball(3) = True And ball(4) = True And ball(5) = True Then
MsgBox "Player-1 Wins"
End If
If ball(6) = True And ball(7) = True And ball(8) = True Then
MsgBox "Player-1 Wins"
End If
If ball(0) = True And ball(3) = True And ball(6) = True Then
MsgBox "Player-1 Wins"
End If
If ball(1) = True And ball(4) = True And ball(7) = True Then
MsgBox "Player-1 Wins"
End If
If ball(2) = True And ball(5) = True And ball(8) = True Then
MsgBox "Player-1 Wins"
End If
If ball(0) = True And ball(4) = True And ball(8) = True Then
MsgBox "Player-1 Wins"
End If
If ball(2) = True And ball(4) = True And ball(6) = True Then
MsgBox "Player 1 Wins"
End If
If cross(0) = True And cross(1) = True And cross(2) = True Then
MsgBox "Player-2 Wins"
End If
If cross(3) = True And cross(4) = True And cross(5) = True Then
MsgBox "Player-2 Wins"
End If
If cross(6) = True And cross(7) = True And cross(8) = True Then
MsgBox "Player-2 Wins"
End If
If cross(0) = True And cross(3) = True And cross(6) = True Then
MsgBox "Player-2 Wins"
End If
If cross(1) = True And cross(4) = True And cross(7) = True Then
MsgBox "Player-2 Wins"
End If
If cross(2) = True And cross(5) = True And cross(8) = True Then
MsgBox "Player-2 Wins"
End If
If cross(0) = True And cross(4) = True And cross(8) = True Then
MsgBox "Player-2 Wins"
End If
If cross(2) = True And cross(4) = True And cross(6) = True Then
MsgBox "Player 2 wins"
End If
End Sub
Sub check_position()
For m = 0 To 8
If Image1(m).Picture = Image2.Picture Then
ball(m) = True
Else: ball(m) = False
End If
If Image1(m).Picture = Image3.Picture Then
cross(m) = True
Else
cross(m) = False
End If
Next
End Sub
Private Sub Command1_Click()
End
End Sub
Private Sub Command2_Click()
For m = 0 To 8
Image1(m).Picture = LoadPicture("")
Next
End Sub
Private Sub Image1_Click(Index As Integer)
check_position
If player = 1 And cross(Index) = False And ball(Index) = False Then
Image1(Index).Picture = Image2.Picture
End If
If player = 2 And cross(Index) = False And ball(Index) = False Then
Image1(Index).Picture = Image3.Picture
End If
check_position
check_status
End Sub
Private Sub Image2_Click()
player = 1
End Sub
Private Sub Image3_Click()
player = 2
End Sub
Private Sub mnuNew_Click()
For m = 0 To 8
Image1(m).Picture = LoadPicture("")
Next
End Sub
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.
PROCEDURE:-
1. Create a new project in VB 6.0, Draw four lines on the form as shown in the figure.
2. Place an Image control on the form, copy it and paste for 8 times (Image Control Array).
3. Now again place Image2, Image3 on the form and add Cross picture and Circle picture for player-1 and player-2 respectively.
4. Place two labels and change the caption as Player-1 and Player-2.
5.Place two command buttons and change their caption property as Play Again and Exit respectively.
Design View:-
PROGRAM CODE:-
Dim cross(8) As Boolean
Dim ball(8) As Boolean
Dim m As Integer
Dim player As Integer
Sub check_status()
If ball(0) = True And ball(1) = True And ball(2) = True Then
MsgBox "Player-1 Wins"
End If
If ball(3) = True And ball(4) = True And ball(5) = True Then
MsgBox "Player-1 Wins"
End If
If ball(6) = True And ball(7) = True And ball(8) = True Then
MsgBox "Player-1 Wins"
End If
If ball(0) = True And ball(3) = True And ball(6) = True Then
MsgBox "Player-1 Wins"
End If
If ball(1) = True And ball(4) = True And ball(7) = True Then
MsgBox "Player-1 Wins"
End If
If ball(2) = True And ball(5) = True And ball(8) = True Then
MsgBox "Player-1 Wins"
End If
If ball(0) = True And ball(4) = True And ball(8) = True Then
MsgBox "Player-1 Wins"
End If
If ball(2) = True And ball(4) = True And ball(6) = True Then
MsgBox "Player 1 Wins"
End If
If cross(0) = True And cross(1) = True And cross(2) = True Then
MsgBox "Player-2 Wins"
End If
If cross(3) = True And cross(4) = True And cross(5) = True Then
MsgBox "Player-2 Wins"
End If
If cross(6) = True And cross(7) = True And cross(8) = True Then
MsgBox "Player-2 Wins"
End If
If cross(0) = True And cross(3) = True And cross(6) = True Then
MsgBox "Player-2 Wins"
End If
If cross(1) = True And cross(4) = True And cross(7) = True Then
MsgBox "Player-2 Wins"
End If
If cross(2) = True And cross(5) = True And cross(8) = True Then
MsgBox "Player-2 Wins"
End If
If cross(0) = True And cross(4) = True And cross(8) = True Then
MsgBox "Player-2 Wins"
End If
If cross(2) = True And cross(4) = True And cross(6) = True Then
MsgBox "Player 2 wins"
End If
End Sub
Sub check_position()
For m = 0 To 8
If Image1(m).Picture = Image2.Picture Then
ball(m) = True
Else: ball(m) = False
End If
If Image1(m).Picture = Image3.Picture Then
cross(m) = True
Else
cross(m) = False
End If
Next
End Sub
Private Sub Command1_Click()
End
End Sub
Private Sub Command2_Click()
For m = 0 To 8
Image1(m).Picture = LoadPicture("")
Next
End Sub
Private Sub Image1_Click(Index As Integer)
check_position
If player = 1 And cross(Index) = False And ball(Index) = False Then
Image1(Index).Picture = Image2.Picture
End If
If player = 2 And cross(Index) = False And ball(Index) = False Then
Image1(Index).Picture = Image3.Picture
End If
check_position
check_status
End Sub
Private Sub Image2_Click()
player = 1
End Sub
Private Sub Image3_Click()
player = 2
End Sub
Private Sub mnuNew_Click()
For m = 0 To 8
Image1(m).Picture = LoadPicture("")
Next
End Sub