13 Replies - 3646 Views - Last Post: 18 May 2013 - 01:41 PM Rate Topic: -----

#1 Raminator  Icon User is offline

  • D.I.C Regular

Reputation: 1
  • View blog
  • Posts: 292
  • Joined: 16-July 12

TextBox.TextChanged on If statement

Posted 17 May 2013 - 12:30 PM

Is it possible to make an if statement with the TextBox.TextChanged event? Something like
If TextBox1.TextChanged Then
blablabla
End If

?
Is This A Good Question/Topic? 0
  • +

Replies To: TextBox.TextChanged on If statement

#2 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon

Reputation: 2298
  • View blog
  • Posts: 9,535
  • Joined: 29-May 08

Re: TextBox.TextChanged on If statement

Posted 17 May 2013 - 12:33 PM

What's wrong with using the TextChanged Event of the Textbox?
Was This Post Helpful? 0
  • +
  • -

#3 Raminator  Icon User is offline

  • D.I.C Regular

Reputation: 1
  • View blog
  • Posts: 292
  • Joined: 16-July 12

Re: TextBox.TextChanged on If statement

Posted 17 May 2013 - 12:37 PM

View PostAdamSpeight2008, on 17 May 2013 - 07:33 PM, said:

What's wrong with using the TextChanged Event of the Textbox?

Its a tic tac toe game, so inside the sub that will start when the user makes his first move, i need to track what the user's next move was, in order for the pc to make the correct next move. Something like
    Private Sub _1_TextChanged(sender As Object, e As EventArgs) Handles _1.TextChanged
        checkV(_1.Text)
        _5.Text = MS
        _5.Enabled = False
'if _2.textchanged then blablbla
'else if _3.textchanged then blablabla
'keep on checking and making moves that will adapt to the players move
    End Sub

Was This Post Helpful? 0
  • +
  • -

#4 andrewsw  Icon User is online

  • say what now
  • member icon

Reputation: 6410
  • View blog
  • Posts: 25,908
  • Joined: 12-December 12

Re: TextBox.TextChanged on If statement

Posted 17 May 2013 - 12:49 PM

I must comment on your textbox names. _1, _5.. seriously? TextBox1 would be better :dontgetit:
Was This Post Helpful? 1
  • +
  • -

#5 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 13566
  • View blog
  • Posts: 54,125
  • Joined: 12-June 08

Re: TextBox.TextChanged on If statement

Posted 17 May 2013 - 12:52 PM

Quote

Its a tic tac toe game, so inside the sub that will start when the user makes his first move, i need to track what the user's next move was,

A collection wouldn't suffice? certainly you number your squares 0 - 8 and just add to a list of(int) which square was picked.

Quote

in order for the pc to make the correct next move. Something like

Why would the computer need to know the last move by the opponent? Isn't the main concern of the game is to solve the current board _as is_ and not _what could be_?
Was This Post Helpful? 0
  • +
  • -

#6 Raminator  Icon User is offline

  • D.I.C Regular

Reputation: 1
  • View blog
  • Posts: 292
  • Joined: 16-July 12

Re: TextBox.TextChanged on If statement

Posted 17 May 2013 - 12:53 PM

View Postandrewsw, on 17 May 2013 - 07:49 PM, said:

I must comment on your textbox names. _1, _5.. seriously? TextBox1 would be better :dontgetit:/>

Hahaha, any suggestions? I made those so i would visualize the tic-tac-toe board on the numeric keyboard
Was This Post Helpful? 0
  • +
  • -

#7 andrewsw  Icon User is online

  • say what now
  • member icon

Reputation: 6410
  • View blog
  • Posts: 25,908
  • Joined: 12-December 12

Re: TextBox.TextChanged on If statement

Posted 17 May 2013 - 12:55 PM

txt1 or txtBox1 ..?
Was This Post Helpful? 0
  • +
  • -

#8 Raminator  Icon User is offline

  • D.I.C Regular

Reputation: 1
  • View blog
  • Posts: 292
  • Joined: 16-July 12

Re: TextBox.TextChanged on If statement

Posted 17 May 2013 - 01:02 PM

View Postmodi123_1, on 17 May 2013 - 07:52 PM, said:

Quote

Its a tic tac toe game, so inside the sub that will start when the user makes his first move, i need to track what the user's next move was,

A collection wouldn't suffice? certainly you number your squares 0 - 8 and just add to a list of(int) which square was picked.

Quote

in order for the pc to make the correct next move. Something like

Why would the computer need to know the last move by the opponent? Isn't the main concern of the game is to solve the current board _as is_ and not _what could be_?

I think didn't express myself quite right, I'll try it again.(Tic Tac Toe Tacticts)
>User makes first move
>Computer, based on the user's first move and the tactics make the next move
>User makes his second move
>Computer, based on the user's second and first move, and computers first move, makes second move
This is basically it. So, if you think of the tic tac toe board as your numeric keypad, something like this should happen: user makes move on square 1,computer makes move on square 5,user-4,computer-9,user-2,computer-7,user-8,computer-3.So the computer would win.
Was This Post Helpful? 0
  • +
  • -

#9 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 13566
  • View blog
  • Posts: 54,125
  • Joined: 12-June 08

Re: TextBox.TextChanged on If statement

Posted 17 May 2013 - 01:04 PM

Okay... so store the values in a collection. One for the player and one for the computer. Their index would indicate which turn they were inserted on so you have your time factor.. the collection keeps them in an ordered structure.. bingo-bango.
Was This Post Helpful? 1
  • +
  • -

#10 Raminator  Icon User is offline

  • D.I.C Regular

Reputation: 1
  • View blog
  • Posts: 292
  • Joined: 16-July 12

Re: TextBox.TextChanged on If statement

Posted 17 May 2013 - 01:10 PM

View Postmodi123_1, on 17 May 2013 - 08:04 PM, said:

Okay... so store the values in a collection. One for the player and one for the computer. Their index would indicate which turn they were inserted on so you have your time factor.. the collection keeps them in an ordered structure.. bingo-bango.

I never did anything with collections before, would this be the right way?
Or this:
Dim local As List(Of Integer)

This post has been edited by Raminator: 17 May 2013 - 01:21 PM

Was This Post Helpful? 0
  • +
  • -

#11 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 13566
  • View blog
  • Posts: 54,125
  • Joined: 12-June 08

Re: TextBox.TextChanged on If statement

Posted 17 May 2013 - 01:47 PM

sure.. make sure it's 'new' though.
Was This Post Helpful? 0
  • +
  • -

#12 Raminator  Icon User is offline

  • D.I.C Regular

Reputation: 1
  • View blog
  • Posts: 292
  • Joined: 16-July 12

Re: TextBox.TextChanged on If statement

Posted 17 May 2013 - 01:51 PM

View Postmodi123_1, on 17 May 2013 - 08:47 PM, said:

sure.. make sure it's 'new' though.

Which one?
Dim local As New List(Of Integer)
?
Also, how would i associate each textbox (each space of teh tic tac toe board) ot an int, and i dont get how would i detect the changes with this.
Was This Post Helpful? 0
  • +
  • -

#13 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 13566
  • View blog
  • Posts: 54,125
  • Joined: 12-June 08

Re: TextBox.TextChanged on If statement

Posted 17 May 2013 - 02:07 PM

Quote

View Postmodi123_1, on 17 May 2013 - 08:47 PM, said:

sure.. make sure it's 'new' though.

Which one?
Dim local As New List(Of Integer)
?


Well..what happens when you try it and see about adding a number or value to it? Does it work? I mean how would you declare and use a complex object?



Quote

Also, how would i associate each textbox (each space of teh tic tac toe board) ot an int, and i dont get how would i detect the changes with this.


Every text box has a unique name, right? They also can have their own unique event for 'text changed' or what ever, right? That means you - the developer - can arbitrarily assign numbers to the text boxes. Which means that every time the top left text box fires off you can have it add '0' to the collection.. which you would create globally.
Was This Post Helpful? 1
  • +
  • -

#14 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon

Reputation: 2298
  • View blog
  • Posts: 9,535
  • Joined: 29-May 08

Re: TextBox.TextChanged on If statement

Posted 18 May 2013 - 01:41 PM

Raminator You are too focused on GUI controls and UI. Design a core ( a model ) that understands the rules of Tic-Tac-Toe. Then interact with that via the UI layer. See my blog for an example.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1