How to break whenever any line of code executes - vb.net

I have a very strange bug, which I believe is caused by some code we have executing, but I'm not sure where.
We can reproduce it to the point it happens whenever we click Tab, but short of putting a break point at the beginning of every method in the project to find out what is executing.
Is there a way to set visual studio to break whenever anything executes?
For those curious about the problem, every now and then, we have a few Rich Text Boxes that refuse to lose focus. You can't click out of it or tab out of it.
We have no On Validation or On Text Changed events attached to the control, and believe it's an event attached somewhere else to something we just aren't noticing.

You can set a breakpoint in the WndProc method, which will run whenever Tab is pressed.

Related

Windows Forms Editor Exception

I'm not even sure how to ask this question, but here goes. The design view of my windows forms object now crashes with the following error:
The control DevComponents.DotNetBar.Office2007RibbonForm has thrown an unhandled exception in the designer and has been disabled.
Exception: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
Stack trace:
at DevComponents.DotNetBar.Office2007RibbonForm.WindowsMessageStyleChanged(Message&
m)
at
DevComponents.DotNetBar.Office2007RibbonForm.WndProc(Message & m)
When the error page pops up, it is this:
I can't think of anything I did before this happened, which is very frustrating. The last thing I did was this:
Add Button on Ribbon Control
Double-Clicked the button to add code
Realized I forgot to name the button, so removed the event code
clicked back on the form tab and BAM. Error.
I tried the following to fix:
Went back and did an undo on the code (re-added the event for that button). But didn't help.
Edited the Designer.vb file to remove that button entirely. Still didn't help.
I thought about pasting my designer code here... I will if that makes sense, but it is so huge I wasn't sure if that was worthwhile. Maybe the above error makes sense to someone besides me???
**** EDIT: Forgot to mention the application runs fine. Just can't edit the form anymore.
OK. I found it. For some reason the form duplicated the style on the ribbon control. Even though the error didn't seem like that one.
FYI - I just kept commenting out stuff in the designer and then trying to launch the form until the error went away. When I finally got to the ribboncontrol, I saw that there were 2 statements:
'Me.RibbonControl1.Office2007ColorTable = DevComponents.DotNetBar.Rendering.eOffice2007ColorScheme.Silver
and
Me.RibbonControl1.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled
As you can see, I commented out the first one and everything worked.

Access VBA: How do I make the VBA editor stop auto-filling values?

I already turned off auto-syntax check but this problem still persists. Whenever I try to modify a time, let's say from 08:30:00 AM to 08:30:05 AM, Access sometimes fills in a zero after I backspace to clear the 0. It forces me to have to quickly change the value otherwise it gives me an annoying pop up message saying syntax error....but the editor caused the error, not me!
How do I fix this? Please help me fix this.
This happens when code is running, which forces Access to constantly compile the VBA source code.
Typical example: a form is open that uses the OnTimer Event (has TimerInterval > 0).
To prevent this: Close all forms while editing code (Design view is ok).
If it's not forms, press the "Stop" button in the VBA toolbar (the blue square) to stop all running code.

vbnet 2008 forms.designer.vb undo bug

I'm having this InvalidOperationException
An error occurred creating the form. See Exception.InnerException for
details. The error is: Object reference not set to an instance of an
object.
pointing at this line of code:
Private Sub BeginningBalancesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BeginningBalancesToolStripMenuItem.Click
inventory.MdiParent = Me <--error here
inventory.Show()
End Sub
EDIT:
Im only using drag and drop for creating controls from the toolbox. The thing here is, everything works fine until I relocated AND decided to return panel_001 to its previous location by pressing ctrl-z in the inventory.vb during design time to revert the change I made. The program runs fine without error prior to that specific panel relocation. I never edited any codes in the designer.vb and in the inventory class. I strongly believe that a piece of code wasn't properly restored at the ctrl-z action in the inventory.Designer.vb. Is this a visual studio bug?
EDIT: I tried creating a new winform and attempted to start fresh by foolishly copying & pasting all the controls and the forms' class and was no good. I assume the problem does not lie under the striked-out line above.
The Winforms designer has a knack for tripping really mystifying design-time exceptions. A side-effect from its strong WYSIWYG design, it will run some event handlers at design-time. Like Paint, making a control look the way it does at runtime. Nice, but that does come with a price. This can easily cause an exception if such an event handler was not written to operate correctly at design time. You are supposed to use the DesignMode property to keep the code safe.
Coming up with a way a Click event handler could run at design-time however requires massive amounts of imagination. That is an event that will not run at design time, the designer uses a layered window that intercepts any mouse clicks, using them for design use instead. Like selecting a control or displaying the design-time context menu.
I have actually seen the Click event of a ToolStripMenuItem run. The designer is not 100% watertight but it happened just once and I was hacking the code pretty hard. Coming up with a way that it could possibly run by using Undo is going to be difficult. Maybe you give it the Ctrl+Z shortcut, don't assume that guess is credible.
The way to deal with incomprehensible black magic like this is to just dismiss it and move on with your life. You just don't stand much of a chance to diagnose it and if you do then there's nothing you can do about it anyway because this isn't your code. Well, other than the need to use DesignMode, that may well be necessary. Not in this case. The only thing you have to watch out for is that such an exception did not destroy the InitializeComponent() method. That can happen too, you notice by controls being missing when you re-open the designer. Very unpleasant, you do need a good backup copy in source control to recover from that lossage.
OK! after giving it a few more tries, I found the answer. After the exception shows, copy exception details to clipboard and then I pasted it on Notepad. It had a lot of texts but the bottom part was the important one:
--insert wall of texts here-- in C:\Users\Ellen\Documents\Visual Studio
2008\Projects\SampleApplication\SampleApplication\Forms\inventory.Designer.vb:line
760 at CabuyaoWaterDist.inventory..ctor() InnerException:
It pointed me out to the specific line in the designer where the ctrl-z did not properly revert one of the label's caption

Why are Break Points ignored in PPT VBA Script called from Actions?

I associated a shape in PowerPoint with an action that delegates to a script in VBA. In the script itself I have defined a break point and provoke an error (just for debugging purposes).
When I run the presentation and I click on the shape, the break point is ignored and no error message is displayed, the code just silently stops at the line where the error is raised.
When I run the VBA script from the event handler of a form button, VBA behaves as expected: the break point is respected and the error message pops up.
Is there an explanation, why VBA behaves differently when executing a procedure called from an action, rather than executing from an event handler or directly from the editor. More importantly: is there a cure, i.e. something I can do to get the expected behaviour in actions?
I am currently using PPT2010 under Win7, but PPT2002 shows the same behaviour.
I've noticed this and similar things before. I'm fairly sure it's deliberate ... if you're in the middle of a presentation, you wouldn't want to see error messages or worse, get dumped into the IDE, so PPT just silently fails.
Try compiling the code once before running it and even try running it manually rather than by clicking the assigned action button.
I've always found problems in my code when breakpoints fail; as long as the code is valid and provokes no errors, the breakpoints work, even when the code's invoked from an action setting.
I have seen the same PowerPoint issue when placing code behind a master slide and other code behind slides that are not master slides. This is all within the same presentation. When calling a sub or function in the master slide from a non-master slide the master slide code executes but breaks are ignored. I am not sure how to articulate this but it seems that the debugging 'commands' from the initiating slide are respected and acted upon as you would expect but not the master slide debugging commands because they lie in a different domain or namespace etc. The debugging processes are only active for one 'domain'. The master and non-master slides do not share the same domain.

Deleting menu item results index error ("source not found")

In VB.Net 2010, whenever I delete a menu item on a Windows Form (a Mainmenu1 object), an exception is thrown at run-time suggesting that there is an index value missing -- essentially a "source not found" error. Do I need to go into the Mainmenu1 object on the bottom of the Form at design time and do something? (BTW, I have also tried deleting the source code for the menu item, and then the menu item, and the exception is still thrown).
Basically, something is occurring that is not allowing me to simply delete a menu item, and get a successful run thereafter.
I had this problem. The simple fix is to restore the menu by clicking undo. Then run the code to make sure it still works. When you have done this, CLOSE visual studio. Then open VS and load your project. Delete the item from the menu and run the project. Everything should be fine
I think you need to specify whether you were trying to delete the menu or menu item during run time, or during design time.
You said, an exception, indicating an index value was missing, thrown at run time. I think it might be depending on how you deleted the menu item. You didn't mention how you deleted the menu item.
Normally, when you choose a menu item from a menu at design time, and press the Delete key, it disappeared. And, the program still works fine.
And, another possibility, is that your form window designer and the background designer code is not properly synced.
You might know that, every .NET form objects, have their background designer code, which serves as a schema for everything on the form.
When you add a button onto the form, the Visual Studio add a line of code in the designer code file (normally if your form name is form1, the designer code file is form1.designer.vb or cs or whatever). When you change the background colour of the button, designer code file add a line of code to set the button's background colour.
So, you see, in your case, when you delete the menu item, your designer code file probably didn't successfully remove the code relating to that menu item. So, it throws an exception at run time.
Maybe, it's because of your Visual Studio installation.
So, my suggestion is, you should try debugging the project, line by line, by running the project with F6 or F11 (sorry, I don't remember the exact key, but you can find it in the Debug menu).
I hope I made a good sense for your problem!