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

Recommended Answers

All 3 Replies

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

commented: Thanks for new Idea ........ +1

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

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.