Click here to Skip to main content
15,943,477 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Dears,
I want to execute the sub method: TESTSub() when the Activated event of Form1 was triggered. But I found the line 'call TESTSub()' is not being executed.

Private Sub Form1_Activated(sender As Object, e As EventArgs) Handles MyBase.Activated
...
call TESTSub()
....
End sub

Private TESTSub()
...
End sub

What I have tried:

I used debug with step by step to check it, it just went through this line, but didn't execute the sub method. But in other events which can call the sub method. What is the problem? Thanks.
Posted
Updated 7-Jan-22 21:20pm

1 solution

We can't tell - we can't run that code at all, so we can't tell what is happening - and you need the debugger to work out what might be going on. Remember that there are two "step" operations in most debuggers: "step into" and "step over" - if you use the later then it will appear not to enter called methods.

So put a breakpoint on the line before the call, another on the line after the call, a third at the start of TESTSub, and a fourth at the end.

Then use the debugger to find out how many of them get hit. Best guess is something is throwing an exception which you are catching elsewhere but with just that fragment of code there is no way we can tell at all!
 
Share this answer
 
Comments
Hu Christian 8-Jan-22 7:55am    
Hi, I have ever put breakpoint on each point, but cannot find the reason. But thanks for your reminder, I re-checked all processes and found the that when the previous form triggers this form, there are some problems within the code. Thanks for your help!
OriginalGriff 8-Jan-22 8:12am    
You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900