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 8464959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:54:21+00:00 2026-06-10T14:54:21+00:00

So I’ve been trying to make a TicTacToe game for a programming class, and

  • 0

So I’ve been trying to make a TicTacToe game for a programming class, and the teacher is useless. :l

When I run the program, 8 times out of 10; when I play and get the grid almost full, it freezes. It’s semi-difficult to explain, and I’m really tired. I hope someone can help. :s

Code:

    Private Sub ChooseBox()
    Dim num As Integer
    Dim Random As New Random
    num = Random.Next(0, 10)

    If Grid_1.Text <> "" And Grid_2.Text <> "" And Grid_3.Text <> "" And Grid_4.Text <> "" And Grid_5.Text <> "" And Grid_6.Text <> "" And Grid_7.Text <> "" And Grid_8.Text <> "" And Grid_9.Text <> "" Then
        gStatus = "Tie"
        Me.Text = "Tic Tac Toe - Nobody won!"
    Else
        If num = 1 And Grid_1.Text = "" Then
            Grid_1.Text = compChar : turnIs = "Player"
        ElseIf num = 2 And Grid_2.Text = "" Then
            Grid_2.Text = compChar : turnIs = "Player"
        ElseIf num = 3 And Grid_3.Text = "" Then
            Grid_3.Text = compChar : turnIs = "Player"
        ElseIf num = 4 And Grid_4.Text = "" Then
            Grid_4.Text = compChar : turnIs = "Player"
        ElseIf num = 5 And Grid_5.Text = "" Then
            Grid_5.Text = compChar : turnIs = "Player"
        ElseIf num = 6 And Grid_6.Text = "" Then
            Grid_6.Text = compChar : turnIs = "Player"
        ElseIf num = 7 And Grid_7.Text = "" Then
            Grid_7.Text = compChar : turnIs = "Player"
        ElseIf num = 8 And Grid_7.Text = "" Then
            Grid_8.Text = compChar : turnIs = "Player"
        ElseIf num = 9 And Grid_9.Text = "" Then
            Grid_9.Text = compChar
        Else : ChooseBox()
        End If
    End If
End Sub

Private Sub CheckResult()

    'First Column is filled
    If Grid_1.Text = compChar And Grid_2.Text = compChar And Grid_3.Text = compChar Then
        gStatus = "Won"
        Me.Text = "Tic Tac Toe - Computer Wins!"
    ElseIf Grid_1.Text = playerChar And Grid_2.Text = playerChar And Grid_3.Text = playerChar Then
        gStatus = "Won"
        Me.Text = "Tic Tac Toe - Player Wins!"
    End If

    'Second Column is filled
    If Grid_4.Text = compChar And Grid_5.Text = compChar And Grid_6.Text = compChar Then
        gStatus = "Won"
        Me.Text = "Tic Tac Toe - Computer Wins!"
    ElseIf Grid_4.Text = playerChar And Grid_5.Text = playerChar And Grid_6.Text = playerChar Then
        gStatus = "Won"
        Me.Text = "Tic Tac Toe - Player Wins!"
    End If

    'Third Column is filled
    If Grid_7.Text = compChar And Grid_8.Text = compChar And Grid_9.Text = compChar Then
        gStatus = "Won"
        Me.Text = "Tic Tac Toe - Computer Wins!"
    ElseIf Grid_7.Text = playerChar And Grid_8.Text = playerChar And Grid_9.Text = playerChar Then
        gStatus = "Won"
        Me.Text = "Tic Tac Toe - Player Wins!"
    End If

    'First Row is filled
    If Grid_1.Text = compChar And Grid_4.Text = compChar And Grid_7.Text = compChar Then
        gStatus = "Won"
        Me.Text = "Tic Tac Toe - Computer Wins!"
    ElseIf Grid_1.Text = playerChar And Grid_4.Text = playerChar And Grid_7.Text = playerChar Then
        gStatus = "Won"
        Me.Text = "Tic Tac Toe - Player Wins!"
    End If

    'Second Row is filled
    If Grid_2.Text = compChar And Grid_5.Text = compChar And Grid_8.Text = compChar Then
        gStatus = "Won"
        Me.Text = "Tic Tac Toe - Computer Wins!"
    ElseIf Grid_2.Text = playerChar And Grid_5.Text = playerChar And Grid_8.Text = playerChar Then
        gStatus = "Won"
        Me.Text = "Tic Tac Toe - Player Wins!"
    End If

    'Third Row is filled
    If Grid_3.Text = compChar And Grid_6.Text = compChar And Grid_9.Text = compChar Then
        gStatus = "Won"
        Me.Text = "Tic Tac Toe - Computer Wins!"
    ElseIf Grid_3.Text = playerChar And Grid_6.Text = playerChar And Grid_9.Text = playerChar Then
        gStatus = "Won"
        Me.Text = "Tic Tac Toe - Player Wins!"
    End If

    'Diagonal Upwards is filled
    If Grid_1.Text = compChar And Grid_5.Text = compChar And Grid_9.Text = compChar Then
        gStatus = "Won"
        Me.Text = "Tic Tac Toe - Computer Wins!"
    ElseIf Grid_1.Text = playerChar And Grid_5.Text = playerChar And Grid_9.Text = playerChar Then
        gStatus = "Won"
        Me.Text = "Tic Tac Toe - Player Wins!"
    End If

    'Diagonal Downwards is filled
    If Grid_3.Text = compChar And Grid_5.Text = compChar And Grid_7.Text = compChar Then
        gStatus = "Won"
        Me.Text = "Tic Tac Toe - Computer Wins!"
    ElseIf Grid_3.Text = playerChar And Grid_5.Text = playerChar And Grid_7.Text = playerChar Then
        gStatus = "Won"
        Me.Text = "Tic Tac Toe - Player Wins!"
    End If
End Sub
  • 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-10T14:54:23+00:00Added an answer on June 10, 2026 at 2:54 pm

    Three problems I see:

    num = Random.Next(0, 10)
    

    Random.Next is lower-bound inclusive and upper-bound exclusive. This means the computer can roll a 0 here. This won’t cause a loop, but it’s slightly wasteful since you never accept a 0 in your conditionals.

    ElseIf num = 9 And Grid_9.Text = "" Then
        Grid_9.Text = compChar
    

    Here, your pattern doesn’t include returning control to Player. I expect the computer would get two turns in this scenario.

    ElseIf num = 8 And Grid_7.Text = "" Then
        Grid_8.Text = compChar : turnIs = "Player"
    

    Now this is the likely loop problem. Notice when the computer rolls an 8 you’re checking grid 7 for contents. So if grid 8 is the last space, you will always fall through to another ChooseBox() call. The loop never resolves.

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

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am doing a simple coin flipping experiment for class that involves flipping a
I would like to run a str_replace or preg_replace which looks for certain words
I want use html5's new tag to play a wav file (currently only supported
I am trying to render a haml file in a javascript response like so:

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.