Code for Focus

Bayne

Member
Joined
Oct 9, 2008
Messages
6
Programming Experience
1-3
Private Sub TxtInterest_Enter()(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TxtInterest.Select

TxtInterest.Select()
End Sub
End Class

For some reason, it's underlining from Byval to TxtInterest.Select
What I'm trying to do is set the focus to go back to my TxtInterest when I press enter. I thought I had it right, but I'm getting a few errors.

Thanks!
Knopp
 
Something you can do is to select your Interest box in designer, go to Properties window and click the Events button (lightning icon) where you doubleclick the event you want. doing this generates the event handler code for you.

Alternative it to go to Code view and use the two comboboxes on top, the left one is where you select the control, the right one you select the event. Same thing happens when you have made the object/event selections, the event handler method is generated for you in code.
 
RE: JohnH

Ok, I clicked the lightning bolt, and I'm double clicking the "Focus-Enter" But it's taking me to this line of code.


Private Sub BtnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnCalculate.Click, TxtPurchase.Enter
mdblInterest = System.Convert.ToSingle(TxtPurchase.Text)
mdblPurchase = System.Convert.ToSingle(TxtPurchase.Text)
End Sub

It took me to the mdblInterest line of code. But didn't add anything.
Is there something else I should be adding there?
Thanks!
Knopp!
 
You have written "Handles BtnCalculate.Click, TxtPurchase.Enter" sometimes before, or selected that combination in the Properties/Events window. If you select one of these events again you are brought to your existing defined event handler as you have now experienced. Is this what you want? Do you really want the BtnCalculate_Click sub method to handle BtnCalculate.Click event and TxtPurchase.Enter event? Is so that is fine, if not you have to change it.
 
Back
Top