ia.solano
ia.solano

Reputation: 558

How to trigger an event after the user lose focus on a?

I am new to visual basic. I have a TextBox, and I want to trigger an event when the user lose focus on the textBox.

I tried writing

Private Sub TextBox_LostFocus()

     something
End Sub

and

Private Sub TextBox_Leave()

     something
End Sub

I don't really understand how they work, I have

Private Sub TextBox_Change()

    something
End Sub

and that works fine, so what am I missing? How do I trigger the event when the user is not writing in the textbox anymore?

Upvotes: 0

Views: 3392

Answers (1)

Joe
Joe

Reputation: 6827

This is what you want:

Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)

End Sub

There's a helper -- when you're in the code editor, you'll see two list boxes above the editor. The list on the left contains the available objects for the current module. Select TextBox from there if it isn't already selected. The list box on the right contains the available Events. You should see Exit in there. Clicking that will paste in the code above.

Upvotes: 1

Related Questions