Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7771151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:34:45+00:00 2026-06-01T16:34:45+00:00

I’m writing a tic tac toe program and i have the board set up,

  • 0

I’m writing a tic tac toe program and i have the board set up, and the game works for the majority. determining who wins. what i am trying to do right now is after a winner is determined, a message box pops up and says who ever wins. I would like the message box to contain two buttons. One button with the text, “Ok for new game” and the second button with the text, “Cancel to exit”. I am using Visual Basic 2010 Express.

Here is the code I have:

Public Class Form1
    Private turn As Integer = 1
    Private play() As String = {"O", "X"}
    Private board(2, 2) As String

    Private Structure arrayIndex
        Dim x As Integer
        Dim y As Integer
    End Structure

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        For x As Integer = 1 To 9
            Dim b As New Button With { _
                .Width = 80, _
                .Height = 80, _
                .Text = "", _
                .Location = New Point(60 + (((x - 1) Mod 3) * 80), 60 + (((x - 1) \ 3) * 80)), _
                .Tag = New arrayIndex With {.x = (x - 1) Mod 3, .y = (x - 1) \ 3}}
            Me.Controls.Add(b)
            AddHandler b.Click, AddressOf buttons_click

        Next
        Me.SetClientSizeCore(360, 360)


    End Sub

    Private Sub buttons_click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        If DirectCast(sender, Button).Text <> "" Then Return
        DirectCast(sender, Button).Text = play(turn Mod 2)
        Dim index As arrayIndex = DirectCast(DirectCast(sender, Button).Tag, arrayIndex)
        board(index.x, index.y) = play(turn Mod 2)
        turn += 1
        winner()
    End Sub

    Private Sub winner()
        Dim rows(7) As String

        rows(0) = board(0, 0) & board(1, 0) & board(2, 0)
        rows(1) = board(0, 1) & board(1, 1) & board(2, 1)
        rows(2) = board(0, 2) & board(1, 2) & board(2, 2)
        rows(3) = board(0, 0) & board(0, 1) & board(0, 2)
        rows(4) = board(1, 0) & board(1, 1) & board(1, 2)
        rows(5) = board(2, 0) & board(2, 1) & board(2, 2)
        rows(6) = board(0, 0) & board(1, 1) & board(2, 2)
        rows(7) = board(2, 0) & board(1, 1) & board(0, 2)

        For x As Integer = 0 To 7
            If rows(x).Length = 3 AndAlso (rows(x)(0) = rows(x)(1) AndAlso rows(x)(0) = rows(x)(2)) Then
                MessageBox.Show(rows(x)(0) & "'s winsssss!", "We have a winner!", MessageBoxButtons.OKCancel, MessageBoxIcon.Information)
            If DialogResult.OK Then
            turn = 1
            ReDim board(2, 2)
            For Each ctrl As Control In Controls
            ctrl.Text = ""
            Next
            Return
            Else
               Me.Close()


            End If
    End Sub
End Class
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T16:34:46+00:00Added an answer on June 1, 2026 at 4:34 pm

    The easiest way to do that is by creating a new Form that functions as a MessageBox. There are many API to customized the MessageBox but gives you extra time. So this is what you are going to do.

    • Create a new Form
    • Set MaximizeButton, MinimizeButton and ShowOnTitleBar to False
    • Set FormBorderStyle to FixedDialog so it will not be sizeable
    • Add two buttons on it (Ok for new game and Cancel to exit)
    • Set StartUpPosition to CenterForm

    Add this code to On for New Game Button (Click event)

    DialogResult = DialogResult.Yes
    

    Add this code to Cancel to exit (Click event)

    DialogResult = DialogResult.No
    

    When the game is finished, try to call the new form you have created.

    Dim xForm as new frmAsk ' Assuming that frmAsk is the name of your new form
    If xForm.showDialog = DialogResult.Yes Then
        ' New game here
    Else
        ' exit game
    End If
    

    Hope this helps you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a text area in my form which accepts all possible characters from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.