hi all

i am using VB6 and is writing a code for a maths project. learners have to enter an answer into a textbox and press enter to mark the given answer. i am currently using a command button to mark the answer, but it is time consuming. the idea is to do as many sums as possible in a limited time span.

thank you

Ta'Nick

I think you want to add events in key press.In this case the simple and easy way is to add this code :

Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyReturn Then
Label1.Caption = Text1.Text
End If
End Sub

Here you can call an even in key press and compare the Key pressed with the key you want ....

And if you want to clean the text after that just add this line

Text1.Text = ""

Try it....
Best of luck ....

Without having to change any of your code you can still accomplish what you want. In the forms design view, highlight the button and then goto its properties. Find the "default" property and make it true.

This property tells the OS that this button is the default button to press when user hits enter key.

Good Luck

Comments
Thanks for new Idea ........

Thank you very much. it works like magic.

hi all

i am using VB6 and is writing a code for a maths project. learners have to enter an answer into a textbox and press enter to mark the given answer. i am currently using a command button to mark the answer, but it is time consuming. the idea is to do as many sums as possible in a limited time span.

thank you

Ta'Nick

This question has already been answered. Start a new discussion instead.