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

  • SEARCH
  • Home
  • 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 6222605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:20:37+00:00 2026-05-24T08:20:37+00:00

Currently I’m trying to fill a 3×3 square with random x’s and o’s to

  • 0

Currently I’m trying to fill a 3×3 square with random x’s and o’s to make a tic tac toe
game. Unfortunately the game doesn’t seem to output all the x’s and o’s. Logically, from what I can see, it should be able to but it’s not. Any help would be appreciated.

Shared Sub twodimension()
    Dim tic(2, 2) As String
    Dim min As Integer
    Dim x As String
    Dim random As New Random()
    Dim i As Integer
    Dim x1 As Integer

    Dim bound0 As Integer = tic.GetUpperBound(0)
    Dim bound1 As Integer = tic.GetLowerBound(1)

    For i = 0 To bound0
        For x1 = 0 To bound1
            min = random.Next(2)

            If min = 0 Then
                x = "x"
                Console.WriteLine("{0}", x)
            Else
                x = "o"
                Console.WriteLine("{0}", x)
            End If
            Console.Write(" "c)
        Next
        Console.WriteLine()
    Next
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-05-24T08:20:38+00:00Added an answer on May 24, 2026 at 8:20 am

    So presumably you’ve got this declaration somewhere, right?

    Public Shared Tic(2, 2) As String
    

    In your code you’ve got GetLowerBound which will (almost) always returns zero and instead you should have GetUpperBound().

        Dim bound0 As Integer = tic.GetUpperBound(0)
        Dim bound1 As Integer = Tic.GetUpperBound(1)
    

    EDIT (in response to comment)

    GetUpperBound(int) returns the highest number that you can use for the dimension that you specify.

    So for the following array:

        Dim MyArray(4, 6, 8) As Integer
    
        Trace.WriteLine(MyArray.GetUpperBound(0)) ''//Returns 4
        Trace.WriteLine(MyArray.GetUpperBound(1)) ''//Returns 6
        Trace.WriteLine(MyArray.GetUpperBound(2)) ''//Returns 8
    

    GetLowerBound(int) returns the lowest number that you can use for the dimension that you specify. In almost every case this is zero but in older versions of VB (and using some COM interop) you can create arrays that don’t “start” at zero and instead start at whatever you wanted. So in old VB you could actually say Dim Bob(1 To 4) As Integer and GetLowerBound(0) would return 1 instead of 0. For the most part there is no reason to even be aware that GetLowerBound exists even.

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

Sidebar

Related Questions

Currently I am trying to make my app available for iOS4, to increase the
currently I am trying to make it so that I can get access to
Currently I am trying to use a bunch of custom perl modules, test.pm as
Currently I'm trying to parse some html and return an array with the values
Currently using Oracle/BEA/Plumtree ALUI Portal 6.1, and am trying to display a client's IP
currently I am trying to replace a simple HTML element to alert the user
Currently when I make a model it goes straight to the collection and saves
Currently I am trying to change the icon of a particular feature of a
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Currently I am making a console game (a rougelike) and I needed some advice

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.