|
-
Jan 7th, 2009, 01:44 PM
#1
Thread Starter
Hyperactive Member
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.
-
Jan 7th, 2009, 02:06 PM
#2
Re: Tic Tac Toe
are they actually entering x or o?
-
Jan 7th, 2009, 02:06 PM
#3
Lively Member
Re: Tic Tac Toe
Maybe you can avoid using textboxes? Use a list maybe...
-
Jan 7th, 2009, 02:17 PM
#4
Thread Starter
Hyperactive Member
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?
-
Jan 7th, 2009, 02:33 PM
#5
Lively Member
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...
-
Jan 7th, 2009, 02:34 PM
#6
Lively Member
Re: Tic Tac Toe
 Originally Posted by ngreenwood6
Also, how do you do a line feed in a messagebox?
Handles TextBox1.TextChanged
-
Jan 7th, 2009, 02:44 PM
#7
Re: Tic Tac Toe
i used buttons when i did mine.
-
Jan 7th, 2009, 02:48 PM
#8
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 .
-
Jan 7th, 2009, 03:50 PM
#9
Thread Starter
Hyperactive Member
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?
-
Jan 7th, 2009, 04:15 PM
#10
Re: Tic Tac Toe
 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.
 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?
-
Jan 7th, 2009, 04:28 PM
#11
Thread Starter
Hyperactive Member
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.
-
Jan 7th, 2009, 04:30 PM
#12
Re: Tic Tac Toe
 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")
-
Jan 7th, 2009, 05:23 PM
#13
Thread Starter
Hyperactive Member
Re: Tic Tac Toe
Thanks that was what I was looking for.
-
Jan 7th, 2009, 05:31 PM
#14
Re: Tic Tac Toe
 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.
-
Jan 7th, 2009, 05:41 PM
#15
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 _
)
)
-
Jan 7th, 2009, 05:42 PM
#16
Re: Tic Tac Toe
Or use a stringbuilder.. they are faster anyway...
-
Jan 7th, 2009, 06:16 PM
#17
Re: Tic Tac Toe
 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.
-
Jan 7th, 2009, 06:21 PM
#18
Re: Tic Tac Toe
maybe, but its also easy to work with since you can call appendline on it when you want to newline.
-
Jan 7th, 2009, 07:19 PM
#19
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
 
-
Jan 8th, 2009, 04:27 PM
#20
Re: Tic Tac Toe
a simple version using buttons
Tic-Tac-Toe.zip
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|