I need to test a very long program that takes many decisions based on live data from an online database. So it is unfeasible to use step in (F8) for an entire run of the program.
I was wondering if there was a way of setting a breakpoint on EVERY line of code of the project. Then when I have tested that line I can clear it and keep running. At the end I will know what part of the program was not tested because it will still have break points.
Any ideas on how to SET EVERY LINE OF A VBA PROJECT TO A BREAKPOINT?
This is not a feature of the VBA Editor. Instead use "Watches"
Related
I have a very hard problem with a project that took me a lot of time to create.
I am desperate at the moment.
I know I was a fool, but now it's just time to find a solution.
In the Workbook.Open() I added a line that calls a function. But unfortunately this function has an infinite loop.
Now i must find a way to open the workbook without running the macro, but then open the VBA code and modify that damn function or least comment that damn line, in order to continue my work.
Please. Help. I need you. I'll send you a reward if you can help me.
Hold Shift while opening your workbook
Another option would be copying the file to another folder, a non-trusted path so VBA won't activate by default when you open it.
I want to use vbs file - which will fire different macros at different hours. I was thinking about putting it in the windows startup programs folder
The point is I want this vbs to fire each of these macros in different hours (Let's assume I will have machine on long enough).
I tried to make separate vbs files for each macro and launch it with windows scheduler. It works, but i dont like this solution and I want to learn smth. To be clear what i want to achieve is:
Launching Computer at 12 -> VBScript is launching at windows start,
then it fires:
Macro a at 13, and update it on 13.15
Macro b at 15
then Macro c at 16 using data from Macro b, and then closing itself
(both macro and vbs).
OFC i will launch computer and close it manually :)
Thanks,
Dawid
You should be able to do this using the timer function which returns the number of seconds since midnight.
https://msdn.microsoft.com/en-us/library/office/gg264416.aspx
To ensure it's not checking every second try the Wait function as well.
https://msdn.microsoft.com/en-us/library/office/ff822851.aspx
I'm still new, so hopefully someone else will expand on this for you, but it should be a good starting point.
as far as I know the only way to register aqlfunctions is via arangosh. JS functions very fastly get a few more lines of code which normally also have line breaks for better understanding. Whenever I paste them into the arangosh it gets corrupt as it excepts to get a "proper" end signal/sign. If I don't know it , the only way to reset it is a shotdown. My questions are:
Is there any shortcut like which resets the line input in such a case?
How can I write JS code into several lines and paste them into the arangosh directly?
Is there another way to register (more complex) JS functions I don't know?
Thanks for your help in advance.
<STRG> + D also works in windows.
Multiline doesn't work well with the CMD, it works partly with the cygwin shell window.
However, if the context shows that a function will start (using a brace) it will offer to add another line until the brace closes.
Probably the easiest way to get in more complex code is:
require("internal").load("c:\\tmp\\test.js")
which will be executed right away, so if you define functions in that, they will be usable in the shell context from then on.
I'm invoking a macro within an Excel document via Powershell.
To invoke the macro, I have to run a named macro and call it in run. However, when the macro is invoked and completes successfully, a MessageBox will appear. As far as I know, this messagebox is the only way to find out if the process has completed successfully.
I have no control over the ability to remove the message box. The powershell script must wait for the macro to finish.
From the document: The documentation for this does not give an option for this situation, or so it appears.
Alternative Options I can work with: (But I'm not sure how to get to the point where the messagebox would be dismissed)
The Excel document can have code inserted within it via Powershell
Options can be changed within the document memory space
Is it possible to run a macro asynchronously and to check back on the execution of the macro?
There are a few convoluted ways to go about doing this.
1) Invoke another instance of the Excel application and run the Macro using that. Then how would you know whether it's done? You pass a global variable by reference to it. And use the OnTime functionality to keep checking every few seconds if its done or not.
An example for calling another excel instance is given here: Stop VBA-Script from "freezing" while sending MDX-Query
2) You can store your script as a .VBS file. Then you call the shell to run the VB script and again check some passed-by-reference variable.
3) Use a hidden worksheet as a buffer, which gets written upon in a particular location once the asynchronous code finishes running. Again, you need some clever OnTime programming to automatically run a polling service... and more importantly, to stop running it!
all!
I'm trying to run programs to control stepper motors. The PC and software and stepper motor controller I have already in place are pretty old and I'm new to almost everything I'm doing here-learning as I go sort of thing. I've 'coded' a bit in Matlab, so I have a very basic level of coding logic, but basically no knowledge of any common syntax. So, I know some about the steppers and the stepper controller, but not much else!
I have a program called "Hoop.exe" that I'm trying to modify to slow down the speed of one of the steppers (I just need to change a 300 to a 200!) when I run the program. There is also an associated (assuming) hoop.bas and a hoop.txt file on the floppy disc. From looking at the txt file, it looks like basic code from examples of basic I've seen. I'm working with visual basic 2.0 and qbasic 1.1 on Windows 98.
So, I tried opening the hoop.bas file first with qbasic and with vb. With qb, I get a 'bad file mode' message. With vb, I get 'invalid file format' and it seems it wants me to open a mak file but I have no 'hoop.mak'. I did this thinking that I could open the bas file with vb or qb, and then edit it, and then save it as an exe, and then run that.
I found a pdf that showed how to incorporate a qb file into the command button of vb, and I tried that. But, I got an "Expected: end of statement" error in the first line! when I tried to save it as an exe.
So, all I really want to do is change my hoop.exe. I would assume that since qb and vb are both on the PC, one of them wrote the bas (maybe not!), so I'm wondering why neither of them can read it.
I've never used vb or qb, but if I have to get into the nitty gritty, it seems like I'd rather use qbasic, since I've never used a graphical interface to code before. But, is either one of those necessary in order to do what I want to do? (I'm going to need to write some programs to control these steppers when all is said and done, but I figured that I should take it one step at a time.)
I tried some form of copying and pasting into qb, but I couldn't immediately figure out how to do that. (Probably because I have no idea how to use qb.)
So, what would be the most efficient way to modify my hoop program?
If the answer is that I just need to learn basic with qb, that's fine, but I'd like to get some sort of indication from people who know what they're talking about before I put that much effort in.
I would really appreciate any pointers because I'm apparently completely clueless on my own!
8/10/2013:
Just in case it's helpful, here are some lines from the Hoop.txt I opened:
10 CLS : CLEAR 1000: P = 512
20 LOCATE , , 1
100 A% = INKEY$: PRINT A$;
105 IF A$ = "*" THEN GOTO 700
110 GOSUB 510: GOSUB 610: GOTO 100
500 REM
510 IF A$ = "" THEN RETURN
etc. This is the beginning of the interface code that allows me to talk to the motor controller
QuickBASIC and Visual Basic are very different, despite their common name of "BASIC" and despite the fact they were both made by Microsoft. First you need to determine if the .BAS file is QuickBASIC or Visual Basic. A simple quick way (though not the most accurate) is to open the file up in Notepad or some other text editor. If keywords such as "OPEN" or "LEN" or "MID" or "CLOSE" are in uppercase, then its more likely a QuickBASIC file. If the keywords look more like "Open" or "Close" or "Len" or "Mid", then its more likely a Visual Basic file.
Now keep in mind that there are other versions of BASIC that have been developed, such as Turbo BASIC (Borland's version) or GW-BASIC or BasicA or PowerBASIC and even Color Basic.
Now if you can't figure it out this way, the next thing I'd suggest is downloading a hex editor, such as XVI32 (though there are many other free ones out there). Look through the file (especially towards the end of the file) and there are usually signs that indicate what kind of compiler was used. You might see the words "Microsoft Basic Compiler" or "Borland Turbo Compiler". Usually towards the end of the file, there are string "stubs" put in by the compiler or linker that you can use to determine the compiler.
If all that fails and you are desperate and that "300" number is hard coded in the program and you need to change it, then there is another way to do this. First back up your original exe file. Then Use XVI32 or some other hex editor and search for the string "2c01" (300 is 012c hex and you need to reverse the 01 and 2c since Intel machines are little-endian). Once you find an instance of 2c01, change it to "c800" (200 is 00c8. Little Endian version would be c800). Save the file, then rerun it. This is a gruesome trial and error way to fix this. If it was changed from 300 to 200, then everything is good! If not, restore from your backup and try again!
Have you considered getting an Arduino or some other low cost and friendly electronics development platform? I think it would be the way to go for you to control stepper motors...
take a look:
http://arduino.cc/en/Tutorial/StepperUnipolar
If you google around you'll find tons of you tube videos showing off some arduino controlled stuff.
Modifying your current .exe seems to me a too long and hard path to follow instead of making your own and proper source code for achieving what you want, as you would need to disassemble the executable file and literally "know what you're doing" with all that assembly language to find where to patch the binary with the right value.
Anyway, if you post a picture or a schematic of your old hardware I could try to help you a little more, but I guess that would be better suited to this other stack exchange site:
http://electronics.stackexchange.com