Results 1 to 8 of 8

Thread: [RESOLVED] Break not working

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2016
    Posts
    109

    Resolved [RESOLVED] Break not working

    I have 2 breaks set in my program. The first time thru both breaks work properly.
    After that, neither break works at all.
    The messagebox after the p1_again only shows up the first time.
    If I go to another program, all the breaks work properly.
    See attached for the break.
    I rebooted the computer several times to see if it would fix the problem.
    Attached Images Attached Images  

  2. #2
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,606

    Re: Break not working

    You are not giving many details here.
    The messagebox will not show the second time if the private sub won't hit or if Player1_Card_nbr <> 5
    Is the private sub breaks?
    If not you are probably not calling it on the second time.
    Also check that you are on debug mode and not release when you run your app.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  3. #3
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    39,047

    Re: Break not working

    Try putting a breakpoint somewhere else.

    Back in VB6, it was possible to skip over breakpoints under certain circumstances, but that changed. I have never seen a breakpoint be missed in .NET...with one exception, and you'd need to be able to see the code to check on that.

    This is not the answer:
    If the code in question is in a dll, then there are circumstances where the breakpoint looks fine when the code isn't running, but when you start the code running, the red ball on the left will become just a red circle with a white (or maybe it's yellow) center. In that case, the breakpoint won't be hit.

    That seems unlikely to be the case here, though, and in those cases, the breakpoint will NEVER be hit, which does not match what you described, because you said it did get there the first time, but not after that. In what I described, the breakpoint wouldn't be hit the first time, or any other time.

    This is back on topic:
    The other possibility, and the one that is virtually certain to be the case, is that the breakpoint isn't being hit because the code that has the breakpoint on it is never executed. You THINK it should be, but it isn't. You even said that the messagebox is only showing up the first time. So, if the messagebox isn't showing up, then the code isn't being executed, so it's no surprise that the breakpoint isn't being hit, since the code it is on is not being executed. You can kind of confirm that by putting a breakpoint somewhere that will be encountered over and over, just to see that it is happening.

    So, why is that code not being executed? I notice that it looks like an event handler without a Handles clause. That suggests that you are hooking up that method to some event using AddHandler. My first guess is that you are encountering a RemoveHandler that you didn't think you were encountering, so the event handler is removed after that first time through. There are other possibilities, but it is something like that. It's not a case of the breakpoints not working. They are working fine, it's just that they are on code that, for some reason, is never reached after that first time through.
    My usual boring signature: Nothing

  4. #4
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,762

    Re: Break not working

    This appears to be a case of a missing handles clause:
    Code:
    Private Sub PLAYER1_OFF(sender As Object, e As EventArgs)
    The above line looks as if it is an event handler for a control. If you're not using AddHandler to manage the event handlers then you'll need to add the handles clause to your sub:
    Code:
    Private Sub PLAYER1_OFF(sender As Object, e As EventArgs) Handles SomeControl.SomeEvent
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  5. #5
    Fanatic Member Delaney's Avatar
    Join Date
    Nov 2019
    Location
    Paris, France
    Posts
    845

    Re: Break not working

    you could also put a "stop" command (just write "stop" where you want), that will act as a break. after that you can go line by line with F8 (VS2010) or F11 (VS2017) or an other depending of the version of VS
    The best friend of any programmer is a search engine
    "Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)
    “They did not know it was impossible so they did it” (Mark Twain)

  6. #6
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    39,047

    Re: Break not working

    Yeah, stop would work...but only if execution gets to that line. If execution was getting to the block with the breakpoint, then the messagebox would have popped up. Since that didn't happen, execution is getting nowhere near that.
    My usual boring signature: Nothing

  7. #7
    Fanatic Member Delaney's Avatar
    Join Date
    Nov 2019
    Location
    Paris, France
    Posts
    845

    Re: Break not working

    I see no use for the second break. The first at the start of the sub should be enough then going step by step should gives what's happen. By the way, if the sub is not called the break will do nothing.
    The best friend of any programmer is a search engine
    "Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)
    “They did not know it was impossible so they did it” (Mark Twain)

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Aug 2016
    Posts
    109

    Re: Break not working

    Stop worked great - thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width