VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



This is the game of ZeroCross made by Vinay.

by Vinay (1 Submission)
Category: Games
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Tue 7th June 2005
Date Added: Mon 8th February 2021
Rating: (1 Votes)

This is the game of ZeroCross made by Vinay.

API Declarations


' make 3 horizontal lines making 3 pairs of horizontal buttons. Name them as Line5,Line6,Line7
' make 3 vertical lines making 3 pairs of vertical buttons. Name them as Line8,Line9,Line10.
' make 2 diagonal lines between diagonal buttons. Name them as Line11,Line12.
' Now place two command buttons differ from array. Name them as cmdNew and cmdQuit.

Option Explicit
Dim i As String
Dim j As Integer


Rate This is the game of ZeroCross made by Vinay.



Private Sub cmdNew_Click()
    If i = "x" Then
        i = "0"
    End If
    For j = 0 To 8
        Command1(j).Caption = ""
        Command1(j).Enabled = True
    Next
    Line5.Visible = False
    Line6.Visible = False
    Line7.Visible = False
    Line8.Visible = False
    Line9.Visible = False
    Line10.Visible = False
    Line11.Visible = False
    Line12.Visible = False
End Sub

Private Sub cmdQuit_Click()
    If MsgBox("Are You Sure ? ", vbYesNo + vbQuestion, "Quitting!...") = vbYes Then
        Unload Me
    End If
End Sub

Private Sub Command1_Click(Index As Integer)
    If i = "x" Then
        i = "0"
    Else
        i = "x"
    End If
    Command1(Index).Caption = i
    Command1(Index).Enabled = False
    
    If Command1(0).Caption <> "" And Command1(1).Caption <> "" And Command1(2).Caption <> "" Then
        If Command1(0).Caption = Command1(1).Caption And Command1(1).Caption = Command1(2).Caption Then
            Line5.Visible = True
            If i = "x" Then
                MsgBox "First Player Wins"
            Else
                MsgBox "Second Player Wins"
            End If
            For j = 0 To 8
                Command1(j).Enabled = False
            Next
        End If
    End If
    If Command1(3).Caption <> "" And Command1(4).Caption <> "" And Command1(5).Caption <> "" Then
        If Command1(3).Caption = Command1(4).Caption And Command1(4).Caption = Command1(5).Caption Then
            Line6.Visible = True
            If i = "x" Then
                MsgBox "First Player Wins"
            Else
                MsgBox "Second Player Wins"
            End If
            For j = 0 To 8
                Command1(j).Enabled = False
            Next
        End If
    End If
    If Command1(6).Caption <> "" And Command1(7).Caption <> "" And Command1(8).Caption <> "" Then
        If Command1(6).Caption = Command1(7).Caption And Command1(7).Caption = Command1(8).Caption Then
            Line7.Visible = True
            If i = "x" Then
                MsgBox "First Player Wins"
            Else
                MsgBox "Second Player Wins"
            End If
            For j = 0 To 8
                Command1(j).Enabled = False
            Next
        End If
    End If
    If Command1(0).Caption <> "" And Command1(3).Caption <> "" And Command1(6).Caption <> "" Then
        If Command1(0).Caption = Command1(3).Caption And Command1(3).Caption = Command1(6).Caption Then
            Line8.Visible = True
            If i = "x" Then
                MsgBox "First Player Wins"
            Else
                MsgBox "Second Player Wins"
            End If
            For j = 0 To 8
                Command1(j).Enabled = False
            Next
        End If
    End If
    If Command1(1).Caption <> "" And Command1(4).Caption <> "" And Command1(7).Caption <> "" Then
        If Command1(1).Caption = Command1(4).Caption And Command1(4).Caption = Command1(7).Caption Then
            Line9.Visible = True
            If i = "x" Then
                MsgBox "First Player Wins"
            Else
                MsgBox "Second Player Wins"
            End If
            For j = 0 To 8
                Command1(j).Enabled = False
            Next
        End If
    End If
    If Command1(2).Caption <> "" And Command1(5).Caption <> "" And Command1(8).Caption <> "" Then
        If Command1(2).Caption = Command1(5).Caption And Command1(5).Caption = Command1(8).Caption Then
            Line10.Visible = True
            If i = "x" Then
                MsgBox "First Player Wins"
            Else
                MsgBox "Second Player Wins"
            End If
            For j = 0 To 8
                Command1(j).Enabled = False
            Next
        End If
    End If
    If Command1(0).Caption <> "" And Command1(4).Caption <> "" And Command1(8).Caption <> "" Then
        If Command1(0).Caption = Command1(4).Caption And Command1(4).Caption = Command1(8).Caption Then
            Line11.Visible = True
            If i = "x" Then
                MsgBox "First Player Wins"
            Else
                MsgBox "Second Player Wins"
            End If
            For j = 0 To 8
                Command1(j).Enabled = False
            Next
        End If
    End If
    If Command1(2).Caption <> "" And Command1(4).Caption <> "" And Command1(6).Caption <> "" Then
        If Command1(2).Caption = Command1(4).Caption And Command1(4).Caption = Command1(6).Caption Then
            Line12.Visible = True
            If i = "x" Then
                MsgBox "First Player Wins"
            Else
                MsgBox "Second Player Wins"
            End If
            For j = 0 To 8
                Command1(j).Enabled = False
            Next
        End If
     End If
End Sub


Download this snippet    Add to My Saved Code

This is the game of ZeroCross made by Vinay. Comments

No comments have been posted about This is the game of ZeroCross made by Vinay.. Why not be the first to post a comment about This is the game of ZeroCross made by Vinay..

Post your comment

Subject:
Message:
0/1000 characters