|
-
Mar 22nd, 2011, 11:07 PM
#1
Thread Starter
Fanatic Member
Break When a Variable Change
Say I have a variable. Say I want to know when does the function change.'
On vs2008 I think on the watch I can edit watch and put something about it. What can I do about it now? There is no such option in the context menu if I click on a watch variable
-
Mar 22nd, 2011, 11:31 PM
#2
Re: Break When a Variable Change
There is no such feature in VS 2008. What you can do is set a breakpoint and then set a condition on that breakpoint, such that execution will break at that point if the value of some expression has changed since the last time execution passed that way.
-
Mar 24th, 2011, 10:50 AM
#3
Thread Starter
Fanatic Member
Re: Break When a Variable Change
I see but what about if I don't know where the value change? I am sure there is such feature in some old version of vb.net. I used it.
-
Mar 24th, 2011, 11:40 AM
#4
Re: Break When a Variable Change
It was a feature in VB6, I have never seen the feature in any version .NET, though I never used 2002.
My usual boring signature: Nothing
 
-
Mar 24th, 2011, 07:12 PM
#5
Re: Break When a Variable Change
VS has a feature to find all usages of a variable. You can use that and set breakpoints. Alternatively, you can use a property and set a breakpoint on the setter.
-
Apr 21st, 2013, 02:38 AM
#6
New Member
Re: Break When a Variable Change
This was a very useful feature in VB6. I am just now (finally) beginning to use VS .net and can't believe there is not a way to do this. Oh well!
-
Apr 21st, 2013, 03:01 AM
#7
Re: Break When a Variable Change
 Originally Posted by jeffdb27
This was a very useful feature in VB6. I am just now (finally) beginning to use VS .net and can't believe there is not a way to do this. Oh well!
I've never once found a need for such a feature and I'm not sure that well-written VB.NET code would ever need it. Generally speaking, there shouldn't be all that many places that any variable's value changes. If the value is to be changed from an external source then it should be exposed via a property so there's really only one place the value should change.
-
Apr 21st, 2013, 09:40 AM
#8
New Member
Re: Break When a Variable Change
 Originally Posted by jmcilhinney
I've never once found a need for such a feature and I'm not sure that well-written VB.NET code would ever need it. Generally speaking, there shouldn't be all that many places that any variable's value changes. If the value is to be changed from an external source then it should be exposed via a property so there's really only one place the value should change.
Well, in VB6 you had public (global) variables that could change all over the place. I am converting a rather large vb6 project and I'm not taking the time (at least at first) to put everything in classes. I am just trying to get it to work.
But in this particular case, i wanted to watch a property of a control, specifcally the selectedtext property of a MaskedTextBox. I cannot get the selection to show (be highlighted) when i set the selection programatically. It shows if selected with the mouse but not in code. This works fine for regular text boxes. I don't think the watch would have helped in this case, but that's why I was looking for it.
-
Apr 21st, 2013, 12:00 PM
#9
Re: Break When a Variable Change
You actually ARE putting everything in classes, though you may not realize you are. EVERYTHING in .NET is in a class. If you put it in a module, the module is quietly turned into a class with all Shared members.
Personally, I did find that feature in VB6 to be quite useful, and have missed it at times over the years. I can only assume that the reason it was removed was that it was accomplished using somekind of ugly hack that MS didn't want to have violating the purity of the current model. That may sound like a rather overwrought reason, but there is at least one other fine example of this: The odd behavior of the Load event on Win64 systems.
Frankly, I made a small amount of use of the MaskedTextBox, but only enough to decide that, as a user, I find it unpleasant. I don't know of a great, and general, replacement for it, but that control is one that I avoid as much as possible.
My usual boring signature: Nothing
 
-
Apr 21st, 2013, 12:13 PM
#10
New Member
Re: Break When a Variable Change
Yes, I know everything is in a class in .net, but you get my point!
I have read other threads where people don't like the MaskedTextBox and say it is something to be avoided. I just dont know why, since all the properties are there (.selectionstart, .selectionlength), that this rather simple code isn't working. The mask part is working fine.
I'll probably abandon it as well. And just use the validate (now validating, I think) function to force proper input.
-
Apr 21st, 2013, 12:21 PM
#11
Re: Break When a Variable Change
I personally feel that the MaskedTextBox is painful to use. This isn't some comment on the quality of the control from a programming perspective, or the properties exposed, I just don't think that it works the way I expect it to work. On the other hand, I can't be more specific than that because it just feels wrong without me being able to say what would feel right. If I could decide what I would prefer it to do, I'd write my own (maybe, I haven't really found all that much use for it, so perhaps I'd do something else), but I can't decide what I don't like about it.
My usual boring signature: Nothing
 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|