textbox1 gotfocus problem

Hi Experts
I have the following code


    Private Sub ModelBox_GotFocus(sender As Object, e As EventArgs) Handles ModelBox.GotFocus      
        MsgBox("wait")
    End Sub

When the mailbox gets the focus
It loops for 30 times
I do not understand why


it should only display wait messagebox once


Please help
b001Asked:
Who is Participating?
 
Jacques Bourgeois (James Burger)PresidentCommented:
Use the Enter event instead. It is called when the control first receives the focus, but won't trigger again unless the cursor moves to another control on the form and comes back. The MessageBox thus have no effect on it.
0
 
Randy PooleCommented:
well it looses focus when the messagebox is show and regains focus when you close it, so it is basically a loop
0
 
Éric MoreauSenior .Net ConsultantCommented:
a msgbox is not a good idea in this case as explained by Randy.

why do you need to put this msgbox there? if it is only to trace it, set a label with the current time and it won't steal the focus
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.