Results 1 to 8 of 8

Thread: Setting Automatic Breakpoints a vb6 Feature in Visual Studio

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2020
    Posts
    70

    Setting Automatic Breakpoints a vb6 Feature in Visual Studio

    In Visual Studio later versions, I'm looking for a debugging feature similar to VB6's "Add Watch." This feature would automatically set breakpoints when specific conditions are met during runtime.

    I've explored conditional execution, but it focuses on checking conditions at existing breakpoints, not before execution.
    Is there a way to achieve this in Visual Studio?
    I'm open to default settings, macros, or third-party extensions for setting automatic breakpoints based on conditions globally.

    I've already looked into:

    1. VB Forum Solution: Setting breakpoints within property setters, but it's challenging for many variables in a large codebase.
    Referred links:
    https://www.vbforums.com/showthread....-value-changes
    https://www.vbforums.com/showthread....ariable-Change

    2. Stack Overflow Forum Solution: Data breakpoints aren't available for managed code in Visual Studio 2019 or earlier
    Tracing variable changes manually - using watch, local or find all reference, but it's impractical for numerous variables.
    Another idea was to track variable usage, store values in an auxiliary variable, and trigger DebugBreak() when values change. However, this approach also becomes impractical with many variables in a large codebase.
    Links:
    https://stackoverflow.com/questions/...tudio-debugger
    https://stackoverflow.com/questions/...ndition-is-met

    None of the above solutions worked for me
    I'd greatly appreciate any insights or recommendations on achieving this functionality. Thank you for your help!

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,103

    Re: Setting Automatic Breakpoints a vb6 Feature in Visual Studio

    I can't say that I've ever wanted to deal with breakpoints on multiple variables across a large codebase. It seems like it would be impractical, as extraneous breakpoints would be continually interrupting whatever it was I wanted to study. I want few breakpoints and always in very narrow locations. When I wanted a bunch of stuff to be tracked, especially changes, I would use some form of logging, not breakpoints.

    Perhaps you could describe a scenario where a lot of breaks on a variety of variables would be useful?
    My usual boring signature: Nothing

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Feb 2020
    Posts
    70

    Re: Setting Automatic Breakpoints a vb6 Feature in Visual Studio

    Thank you for the quick response. I want to clarify my question: I'm not actually looking to monitor multiple variables. In VB6, there was a feature where you could set a watch on a single variable, and the debugger would stop when that variable's value changed, regardless of its location in the code. Does a similar feature exist in later versions, and if so, how can I use it?

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,103

    Re: Setting Automatic Breakpoints a vb6 Feature in Visual Studio

    Ah, I remember that feature. It was useful. I don't think that a solution as clean as that one exists in VS, these days. You can do a whole lot with breakpoints, including some odd conditional breakpoint actions, so you might well be able to do the same thing, but not quite as easily. Debug execution works differently in VS than it did in VB6, which may preclude that specific functionality. In VB6, what got executed in debug was not necessarily the same code that was written, which meant that some breakpoints wouldn't be hit because execution could take a different path when there was a breakpoint than the path it took without a breakpoint. I can't say exactly what was going on there, but it no longer happens, so debug functionality is different. I have always suspected that whatever change was made was the reason behind any other changes I saw.
    My usual boring signature: Nothing

  5. #5
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Posts
    12,371

    Re: Setting Automatic Breakpoints a vb6 Feature in Visual Studio

    That does sound like a useful feature but apparently Visual Studio does not support a Break When Value Changes debugging feature.

    An alternative that I found is that you can create a property in My.MyApplication and setup a breakpoint in the setter function:
    1. Go to Project > {Project Name} Properties's Application tab
    2. Click on the View Application Events button
    3. Add the following property:
      Code:
      Private _watchedProperty As String
      Public Property WatchedProperty As String
          Get
              Return _watchedProperty
          End Get
          Set(value As String)
              If Not _watchedProperty.Equals(value) Then
                  _watchedProperty = value
              End If
          End Set
      End Property
    4. Setup a breakpoint where it is setting the value of _watchedProperty


    Now you could even backtrack where the value changed from by looking at the stack trace.
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | HtmlLessons | CssLessons | Code Tags | Sword of Fury - Jameram

  6. #6
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Setting Automatic Breakpoints a vb6 Feature in Visual Studio

    That also assumes you have the code to the property ... if it isn't something you created, or if it's not a property but a field in the class... then you're kinda sol ... which really really sucks. that was one feature I used a lot back in those days. Times when I wish I could do hte same in my Java code ... where/when the hell is this being changed at?


    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  7. #7
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,103

    Re: Setting Automatic Breakpoints a vb6 Feature in Visual Studio

    Yeah, where IS it being changed at? There are times when I have found it to make sense to find every location where the variable is set, and put breakpoints on all of them. Of course, that only really works when you know what problem you are looking for, or else you'll hit lots of irrelevant breakpoints.
    My usual boring signature: Nothing

  8. #8
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,969

    Re: Setting Automatic Breakpoints a vb6 Feature in Visual Studio

    Please remember next time...elections matter!

Tags for this Thread

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