0

Team -

Working on a personal project to help with my sons spelling.

I can't seem to find an easy solution to this so I hope someone can point me in the right direction.

Textbox 1 will hold the correctly spelled word.
Textbox 2 will be typed BUT I want the background of textbox2 to change green if he is on track but turn red when he messes up on a letter.

Basically I need the two boxes to be validated each time he presses a key. I can do the box to box when complete but the trick I am having is how to I have them check as he is typing?

Thanks!

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by bluem1
0

Use the TextChanged event.

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

        If (TextBox1.Text.StartsWith(TextBox2.Text)) Then
            TextBox2.BackColor = Color.LightGreen
        Else
            TextBox2.BackColor = Color.Salmon
        End If

    End Sub
0

That works exactly right. Thanks for the .StartsWith, I had never heard of it before!

You just saved me tons of time. I was working with determining lengths and doing trims based on lengths etc. and have the two boxes compare letter by letter but this is MUCH easier.

Thank you again!
Dewayne

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.