Hi,

Basically, what I'm trying to do is that once the user has entered player names into two seperate text boxes, the user will then click the "Play" Button, this button will then change it's text to say "Quit". How would I go about doing so that once the button has been pressed again, that now says quit, it clears the player name text boxes?

This is what I have so far:

Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
        If (TextBox1.Text.Length < 0) Or (TextBox2.Text.Length < 0) Then
            MsgBox("You must enter a Name for Player 1")
            MsgBox("You must enter a Name for Player 2")
        ElseIf (TextBox1.Text.Length > 0) Or (TextBox2.Text.Length > 0) Then
            Button10.Text = "Quit"
            Me.Button10.BackColor = Color.Red
        End If

As you can see, it's not very far. ^_^ I just can't figure out how to do this.

Thanks,
Chris

How about

Public Class Form1

    Private Sub TextBox1_TextChanged(sender As System.Object, e As System.EventArgs) Handles TextBox1.TextChanged
        SetPlayQuit()
    End Sub

    Private Sub TextBox2_TextChanged(sender As System.Object, e As System.EventArgs) Handles TextBox2.TextChanged
        SetPlayQuit()
    End Sub

    Private Sub SetPlayQuit()

        'If we are not currently playing a game, this sub will disable the
        'play button if either of the player text boxes is empty.

        If btnPlayQuit.Text = "Play" Then
            btnPlayQuit.Enabled = TextBox1.Text <> "" And TextBox2.Text <> ""
        End If

    End Sub

    Private Sub btnPlayQuit_Click(sender As System.Object, e As System.EventArgs) Handles btnPlayQuit.Click

        Select btnPlayQuit.Text
            Case "Play"
                btnPlayQuit.Text = "Quit"
                TextBox1.Enabled = False
                TextBox2.Enabled = False
            Case "Quit"
                btnPlayQuit.Text = "Play"
                TextBox1.Clear()
                TextBox2.Clear()
                TextBox1.Enabled = True
                TextBox2.Enabled = True
                'add code here to start playing
        End Select

    End Sub

End Class

You don't really need to enable/disable the textboxes but it does prevent changing the values while the game is in play.

This worked perfectly! Thank you very much. I'm not aware of cases, will have to look into it.

Again, thanks! :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.