text input matching label question

My problem is that I can't figuire out how to code this simple situation:( I have one textbox and a label that displays a random letter. I want a if,then statement when a key pressed in the textbox to check if the two are the same letter without having to hit enter. I have it working with the user having to to hit the enter key after they type the letter but I want to get rid of the enter key step.
Thanks for the help
[426 byte] By [newbieneedshelp] at [2007-12-24]
# 1

in the textbox, simply implement a keypress event. In your designer view of the form, select the textbox, then in the properties of the textbox, choose the events icon "lightning" symbol and double click the keypress event to create this event handler.

Now in here you will compare the keychar to what the label has, from the arguments (KeyPressEventArgs) in this event.

What will happen is when you press the key in the textbox, it will automatically "fire" or "raise" the event so whatever code has been implemented here would be executed.

so in this event, try perhaps this:

if e.KeyChar.ToString().ToLower().Equals(Me.theLabel.Text) then

'the key pressed matches the text in the label

end if

This will only work successfully, if the text in the label is 1 character.

does this help?

ahmedilyas at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic Language...
# 2
Siimple as that!!! Worked great, Thank you
newbieneedshelp at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic Language...
# 3
glad I could help!
ahmedilyas at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic Language...