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!

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

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

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.