Track Changes to a variable

Posted on 2005-04-18
Last Modified: 2010-04-23
how do i track the changes made to a variable... i want to know what is changing the varaible and where in code it is located.  
Question by:BangorCC
    LVL 3

    Expert Comment


    I don't know if this looks practical but if you replace your variable by an object and implemenet some code for that class so it can keep track of previous changes, that might solve your problem.

    A class like this emulating a string variable would be something like:

        Class StringTrack
            Dim sValue As String
            Public Property Value() As String
                    Return sValue
                End Get
                Set(ByVal Value As String)
                    sValue = Value
                End Set
            End Property
        End Class

    And you use it like:

            Dim sTrack As New StringTrack
            sTrack.Value = "HELLO"
            sRead = sTrack.Value

    And/or you can create a method called like SetValue that accepts additional parameters that provide details you can save in your internal track log for further analysis.

    LVL 25

    Accepted Solution

    You could add the variable to a watch (right the variable, choose quickwatch, choose add watch), and use this together with the call stack window to trace the changes made to the variabele

    Author Comment

    not quite what i was looking for but it works

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
    Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now