Results 1 to 20 of 20

Thread: Tic Tac Toe

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2009
    Posts
    448

    Tic Tac Toe

    I am just creating a simple tic tac toe game. I have created text boxes where the users can click and it will enter an X or an O. The only thing I do not like is that it has the blinking cursor next to it. I have it set as read only. Is there anyway to make the cursor go away.

  2. #2
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: Tic Tac Toe

    are they actually entering x or o?
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  3. #3
    Lively Member briedis's Avatar
    Join Date
    Nov 2008
    Location
    Latvia
    Posts
    79

    Re: Tic Tac Toe

    Maybe you can avoid using textboxes? Use a list maybe...

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2009
    Posts
    448

    Re: Tic Tac Toe

    no when they click the box it enters an X or an O they don't actually type the letter. Also, how do you do a line feed in a messagebox?

  5. #5
    Lively Member briedis's Avatar
    Join Date
    Nov 2008
    Location
    Latvia
    Posts
    79

    Re: Tic Tac Toe

    Hmmm, I think you can use a button, beacause, first start x or o, then the other will be oposite. What is the point of typing, if you have only x or o to write. You just have to select a free spot where to put your symbol...

  6. #6
    Lively Member briedis's Avatar
    Join Date
    Nov 2008
    Location
    Latvia
    Posts
    79

    Re: Tic Tac Toe

    Quote Originally Posted by ngreenwood6
    Also, how do you do a line feed in a messagebox?
    Handles TextBox1.TextChanged

  7. #7
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: Tic Tac Toe

    i used buttons when i did mine.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  8. #8
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: Tic Tac Toe

    You could use PictureBoxes and when the user clicks on one you load either the X or the O image in its place. That's how I did mine back in the day .
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2009
    Posts
    448

    Re: Tic Tac Toe

    First of all, it really irks me when instead of answering your question people just go around and say do this instead. I like the way that I have my X's and O's set-up and it is working no need to change it. Secondly, how do i use this in the messagebox:

    Handles TextBox1.TextChanged
    Lastly, can anyone answer my question about making the blinking cursor disappear from a textbox? Maybe change its focus or something?

  10. #10
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: Tic Tac Toe

    Quote Originally Posted by ngreenwood6
    First of all, it really irks me when instead of answering your question people just go around and say do this instead. I like the way that I have my X's and O's set-up and it is working no need to change it.
    The way you were doing it created less than desirable results due to the cursor so I offered an alternative. I'm not sure how to remove the cursor though it seems kind of silly since a textbox is meant to have a cursor. You could even use a label if you prefer and put a border around it.
    Quote Originally Posted by ngreenwood6
    Secondly, how do i use this in the messagebox:
    Not sure what you mean. That code will handle the text change event in the textbox. Do you want to display the text in a message box whenever it's changed? What is your desired result?
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2009
    Posts
    448

    Re: Tic Tac Toe

    kasracer, briedis told me to use that code to enter a line feed in a messagebox. Basically all I am trying to do is put something on one line and something else on another line in a messagebox. Looking for a carriage return/linefeed

    edit: oh and by the way I changed the focus to another object after the box is clicked to get my desired results.

  12. #12
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: Tic Tac Toe

    Quote Originally Posted by ngreenwood6
    kasracer, briedis told me to use that code to enter a line feed in a messagebox. Basically all I am trying to do is put something on one line and something else on another line in a messagebox. Looking for a carriage return/linefeed
    Oh I get it. You can just use Environment.NewLine for that.

    For instance if I want 3 lines in my MessageBox I can do this:

    Code:
    MessageBox.Show("First" & Environment.NewLine & "Second" & Environment.NewLine & "Third")
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  13. #13

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2009
    Posts
    448

    Re: Tic Tac Toe

    Thanks that was what I was looking for.

  14. #14
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Tic Tac Toe

    Quote Originally Posted by ngreenwood6
    First of all, it really irks me when instead of answering your question people just go around and say do this instead. I like the way that I have my X's and O's set-up and it is working no need to change it.
    You need to get used to people providing alternate suggestions when posting a question on a public forum. You said yourself you are a newb to VB and programming, so why would you object to veteran developers giving you advice on how to implement something that is a better design than your current one? You need to be open to suggestion and criticism, even if you don't end up using it in the end.

    If you are asking a question about the blinking cursor in the textbox, then it actually DOESN'T sound like its working, and least not working exactly how you want it to.

    The other thing you probably did wrong was you went ahead and made 9 textboxes already on the form to be your X/O spots, and then realised you had a problem with the cursors blinking. So now you don't want to change it because you already put a good amt of time in, and to change all 9 boxes now is a pain. You should get 1 box working, exactly how you want it to, then replicate it to the other boxes once 1 is working.

  15. #15
    Frenzied Member MaximilianMayrhofer's Avatar
    Join Date
    Aug 2007
    Location
    IM IN YR LOOP
    Posts
    2,001

    Re: Tic Tac Toe

    Or if you'll be using Environment.NewLine alot, then you can increase readability like this:

    Code:
    MessageBox.Show( _
        String.Format( _
            "First{0}Second{0}Third{0}Fourth{0}Fifth", _
            Environment.NewLine _
        )
    )

  16. #16
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Tic Tac Toe

    Or use a stringbuilder.. they are faster anyway...

  17. #17
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: Tic Tac Toe

    Quote Originally Posted by kleinma
    Or use a stringbuilder.. they are faster anyway...
    True but only if you're concatenating quite a few strings. If you're only doing a handful then it's overkill because the StringBuilder is a bit heavy.
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  18. #18
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Tic Tac Toe

    maybe, but its also easy to work with since you can call appendline on it when you want to newline.

  19. #19
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,109

    Re: Tic Tac Toe

    Before you go rushing into Stringbuilder, take a look at what Mendhak had to say here in #13:

    http://www.vbforums.com/showthread.php?t=552241

    However, don't read on to his next post, which I think was #15, as he strained his tongue reaching for a pun.

    By the way, while the textbox solution for the Xs and Os will work fine, there is a good reason to consider using pictureboxes instead: Once you have this program working, you will have a Tic-Tac-Toe game. How long will you play that? Probably not very long. More fun to create than to use, in the long run. So what next? There's a slight variation on the standard Tic-Tac-Toe game that makes the game far more challenging. The variation requires that the cell have a visible number, as well as the X or O or Empty, that you currently have. Adding the number with textboxes won't work as well, but with Pictureboxes, you just need to change the graphic a little bit to switch the display to the tougher form of the game.
    My usual boring signature: Nothing

  20. #20
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: Tic Tac Toe

    a simple version using buttons

    Tic-Tac-Toe.zip
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width