What happened to Watch Points?

S

Selden McCabe

In Vb6, there was a feature called (I think) watchpoint. You could set it
to break on a condition, such as when a control's Visible property was
changed.

I can't find this sort of breakpoint in VB.Net, is it there?

If not, I have a fairly complex project where a text box which is supposed
to be invisible is being set Visible somewhere. I've searched, and there
isn't any code doing it directly (e.g. txtPhone.Visible = True). I think
there's probably some code walking through the controls collection, setting
everything to visible, or something like that.

How could I track this type of siutation down without VB6's watchpoints?

Thanks,
---Selden
 
T

Telmo Sampaio

Check the properties of a breakpoint. Create a breakpoint, right click it
and select properties. You should see a condition option.

Telmo Sampaio
 
H

Herfried K. Wagner [MVP]

* "Telmo Sampaio said:
Check the properties of a breakpoint. Create a breakpoint, right click it
and select properties. You should see a condition option.

I doubt that this is what the OP is looking for, because it would
require you to know the line of code that is changing the property.
 
S

Selden McCabe

Hi Telmo, Thanks for the reply.
I see the condition on the breakpoint.
But what if I don't have any idea WHERE the code is that's setting the
control's property?
Where would I set the breakpoint?

Anyway, I added some code to the VisibleChanged event for the control, set a
break point there, and found it that way.

---Selden
 
T

Telmo Sampaio

Yes and no.
Place a breakpoint on the MessageBox line of button2_click and set its
condition to *when x has changed*. Althoug X is changed in the button1_click
method the breakpoint in button2_click will occur.
Dim x As Integer

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

x += 1

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click

Dim y As Integer

y += x

MessageBox.Show(y)

End Sub
 
T

Telmo Sampaio

That's the problem, you need to specify a place for the breakpoint. I just
posted an answer to Herfried about this, using two buttons and making the
change on button1 and breaking on button2. Again, it is not perfect, but it
is the only way I know for doing what a watch condition did in VB6.

Telmo Sampaio
 
S

Selden McCabe

Thanks Telmo, for this information.

This looks pretty cool, I didn't know you could do that with a breakpoint!

I tried setting this up by setting a breakpoint on one line of code in the
form, and then set the condition to:

txtPhone.Visible

has changed.

When I ran the project, the textbox went from not visible to visible, but
the breakpoint didn't get hit.

Can you think of any restrictions on what line of code you put the
breakpoint on?

My first attempt was in an unrelated module (not the form that contains the
text box) and it complained that it couldn't set the breakpoint.
(I had set the condition to "frmConsumer.txtPhone.Visible" - similar to the
way it worked in VB6).

So obviously the breakpoint must be somewhere where the variable is in
scope.

Or maybe this just doesn't work for properties of controls?

Anyhow, thanks again for the advice, I've already learned something new
about breakpoints!

---Selden
 
H

Herfried K. Wagner [MVP]

* "Telmo Sampaio said:
Place a breakpoint on the MessageBox line of button2_click and set its
condition to *when x has changed*. Althoug X is changed in the button1_click
method the breakpoint in button2_click will occur.

OK, that would work indeed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top