Skip to content

Computed Property Tips for Debugging

Here are a couple tips you can use with computed properties.

Read-Only Computed Properties

When you create a Computed Property, you’ll get a section call Get and a section called Set. The Get section is where you put the code to return the value for the property and the Set section is where you put code to set the computed property value. Did you know you do not have to fill in both sections?

If you leave the Set section empty, you’ve created a read-only computed property. You’ll be able to get its value as per usual but if you try to set a value you’ll get a compile error. This can sometimes be a great alternative to using a method because the computed property value appears in the debugger.

The sections with code are shown in bold so you can tell a read-only property because only its Set section will be bold.

Break on Usage

When debugging you may have situations where you would find it helpful to know when one of your property values changes. You can do this by changing a regular property to a Computed Property. To do this, right-click on the property and choose “Convert to Computed Property”. You’ll now have two related properties: a private “backing” property with a prefix of “m” (for example mLastName As String) and a corresponding Computed Property with the original name (for example LastName) that uses the private property to get and set its value.

In the Get and Set sections you can now set breakpoints on the code there so you’ll drop into the Debugger any time the property is accessed or changed.

More Debugger and Computed Property tips are here: