vb6 how to enter in debug mode while in msgbox - debugging

I've made some searches but not found this question, sorry.
In a vb6 loop Ive a msgbox showed.
Any way to enter in debug mode (as using F8) ?
I need this in order to change the conditions of the msgbox.
And not, I can't restart the project because then I will lost the changes and the time the array took (several hours).
TIA.

Assuming you are running in Debugger when the MsgBox shows, press Ctrl + Break to interrupt the MsgBox and drop into single-line stepping.

you can use breakpoints-you mark the point in code by clicking on the bar near the code and then you run the code at the moment the instruction pointer gets to this point you will see the code and the values at this point.
hope this helped.

Related

Visual Studio: Is there a way to skip execution of code between two breakpoints?

I know I can comment the code but would be even better if there is a shortcut to skip execution of code between two breakpoints.
VS has a feature 'set next statement' which moves the program counter to the to that location and continues execution from there (skipping anything in between). You can read more about it at: https://learn.microsoft.com/en-us/visualstudio/debugger/navigating-through-code-with-the-debugger?view=vs-2017#BKMK_Set_the_next_statement_to_execute. The easiest way to use it is to either use the context menu item "Set Next Statement" (right click on where you want to set it) or hold down the ctrl key which changes the green "Run to click" editor glyphs into yellow "Set next statement" glyphs and just click on where you want to set it.
Set next statement is a great tool but it's really dangerous as a debugging tool. You're using the debugger to execute code in a way which would never happen normally. The results of which could cause crashes or other failures easily. It's real easy to do things like skipping over the initialization of a variable that's later used and will now cause an exception/crash.
It can be used in JS, .NET and native.

AHK in Visual studio 2013

I'm using a shortcut to remind me to use two equal signs to check for equality. heres my AHK code:
::if::
Send, if
MsgBox Use two equal signs to check for equality!
Return
When I type 'if' it will bring up the box and keep the if the first time, after that it eats up the 'if' and doesn't print it. The code works fine for any other application but I can't get it to work in Visual Studio 2013. Also, it seems to work as expected when I try it in a comment. Any help would be appreciated!
Attaching the option B0 to a hotstring prevents it from removing the previously typed phrase, so you don't have to re-send if again:
:B0:if::
MsgBox Use two equal signs to check for equality!
Return
I know you already have your answer, but I personally would hate a MsgBox every time I typed "if". You may want to look into using context sensitive hotkeys. Furthermore, instead of a MsgBox, you could use a less invasive ToolTip. This way, you could keep typing but still get notified.
CoordMode, Caret, Window
:B0:if::
ToolTip, Use two equal signs to check for equality!, % A_CaretX, % A_CaretY+20
Sleep, 3000
ToolTip
return

Going back to previous line while debugging on visual studio

I am debugging a piece of code on visual studio and I forgot to note down the values I have kept a watch on. Can I go to previous line without rerunning the entire code?
There are similar questions asked on SO but in my case i haven't run through any error or exception. The code is running normally.
After pausing on a break point, right click on the line you want to "go back" to. From the menu that pops up, select "set next statement".
This will adjust the instruction pointer to continue from the specified line of code, but it will not roll back any variables or memory addresses to the values they were at before that line of code was originally executed.
It sounds like what you want to do is rewind / replay your code rather than just move to a specific line. You can move to a specific line, you can just right click and choose set next statement. Unfortunately, this won't rewind the state of the program to some past point (beyond setting the stack and doing a bit of unwinding).
To rewind/replay you need to be a bit trickier. Some options are: -
VMWare replay which will allow you to record and then go back to a certain point in time.
Intellitrace. I haven't tried it, but it allows you to replay to a point.
Which is a bit heavyweight and wont help you right now.
You can use the mouse to drag the yellow arrow pointing to the "next statement to be executed." This actually changes which statement will be executed next. It's not guaranteed to work, but as long as the code is not too complex, it could.

vb6: interrupt endless msgbox loop

I am writing a program in VB6.
By mistake many times my code contains an endless loop, inside which there is a message box. For example:
while a>0
msgbox "a is positive"
wend
Then I press the play/run and I realize what has happened. Is there any way to stop the debugging/running of my program?
The only thing that works so far is Ctrl+Alt+Del and end task. But this way the whole visual basic closes and I lose my unsaved data. (please don't comment that I should save my program more often. I know it (now)).
Edit: I found on the internet that maybe esc or ctrl+c or ctrl+break could do the job. The first two do nothing and my laptop doesn't have a break key
Solution: I have the insert key in my laptop. on the key there is also written pause for use along with the Fn key. So I was able to break the application by pressing Ctrl+Fn+Insert (which maybe could be translated in Ctrl+Pause)
edit: link to photo of my keyboard:
ctrl + break will work. If you don't have those keys, use the on screen keyboard.
Start | Run | osk
Then press ctrl + break.

Visual Studio debug jump out of loop

I know about basic features of visual studio debugging. F10, F11, Shift+F11, Ctrl+F10.
If I am inside a for loop is there a way of stopping right after the loop is completed?
Right now the way I am doing it is to manually go to the location after the loop and press Ctrl+F10. Is there a better way of doing this?
There is no dedicated "Step Out of Loop" command in Visual Studio. "Step Out" (Shift+F11) works only for functions. There are only two options that I can think of:
Like Brian suggests, there is Run to Cursor, which has been there at least since VC++ 6. This is what you're already getting with the Ctrl+F10 keyboard shortcut. I use this literally all the time while debugging; it's an extremely useful tool. I don't really understand why you think this is a lousy way of doing it, or why you think there should be a "better" way.
You could set a simple breakpoint on the line of code immediately following the loop. This is relatively simple if you use the keyboard shortcut F9. But you still have to navigate to the appropriate line of code, so you might as well use Run to Cursor.
If you're working in a C-derived language, your loops probably conclude with a }. So you could use the Ctrl+] keyboard shortcut to move to the matching brace in the source file if your caret is at the loop's opening brace. That might make navigation easier. It certainly can help avoid moving your hands over to the mouse, killing precious seconds.
* Note that keyboard combinations are subject to change, depending on how you have configured your Visual Studio environment.
I just found out that if you hover with your cursor at beginning of the desired line, VS automatically blends in a little play symbol. When you click on it, debugger jumps to this point.
Perhaps you would like to use a breakpoint, which can be used to trigger the debugger once your program has reached a specific line. You can set one by clicking on the left side of the code line, where errors and arrows usually show up during debugging. Hope this helps!
Simple way is to put a break statement in the for loop and add a condition. This will allow you to test the loop while debugging.

Resources