Excel VBA slows down when excel is not the front window - performance

I have many different VBA macros that are commanded to run by an analysis sequence this analyser sequence and a Labview VI also reads and takes information that has been calculated in the excel spreadsheet.
The analysis sequence has timers and delays that you can see counting down during which it checks on the status certain cells of the excel spreadsheet.
All the analysis sequences, excel VBA macros and Labview VIs work perfectly but only when the excel window is running in front. if any other window is selected the calculations slow down which means the delay timers shown on the other sequences also slow down 5 or 6 times slower.
This becomes a problem because the Labview VI has buttons to select options meaning in normal operation the excel sheet won't be in front.
I have tried changing priorities in the task manager which changes nothing and making things run on different CPUs which again does nothing. the CPU is running around 50% all the time but the CPU usage of excel jumps from 2 or 3 when excel window is up front to around 50 when another window is selected.
I've also made the macros as streamlines as i can think of doing by turning of screen updating and so on.
A fix like the VBA code bringing the sheet to the from will be just as good as having the excel window permanently at the front. but an idea of what could be causing the issue would be much appreciated.
Thank you in advance

You could try setting your Windows environment to adjust for best performance of background services.
http://www.ni.com/white-paper/3773/en/

Related

QA testing a clipboard operation

One of the components on our website, when clicked, copies its content onto the clipboard, and during the copying operation a tooltip is shown that says 'Copying...'
The copying process is almost always instantaneous, however... So how can my Quality Assurance colleague test that the tooltip is appearing? Is there any way to artificially slow down clipboard operations on a Mac, or on a PC for that matter?
This is a black-box type operation, so a suggestion that requires me to add a delay or logging to the code temporarily, for testing purposes, is not a viable solution.
Your question is not specific enough however I'll try to give you a clue. Copying to clipboard is implemented with the help of JavaScript. So there are few ways of how to achieve this. Find them here https://stackoverflow.com/a/30810322/8343843.
So depending on which approach is used in your case, you may do a sort of reverse-engineering (if you don't really have the developer guys available), set up break-point to the place where actual copy step is performed (using browser dev tools) and then execute code line by line. Depending of how the tooltip is implemented there is some quite high probability that you will see your tooltip for longer time.
You may also set a DOM-breakpoint that would be listening the DOM change. This will help you to freeze the tool-tip if it is implemented as a DOM node.

Continuous Progress Bar

Using VB6
I want to show the continuous progress bar during the code running time.
Progress bar continuously should run. Once the coding process is completed, the progress should be invisible.
How to make a code for the continuous progress bar
Need VB6 code Help
This is tricky to do if you have continuously running code, since VB6 is single threaded.
I've tried doing this myself (setting the width of a label control with a coloured background), but the GUI tends not to re-draw. I ended up dividing the work up into sections and calling DoEvents at the end of each section. The GUI update was rather coarse.
There are ways of running multiple threads in VB6 - but they need very careful handling - and from there you might be able to run code in one thread and update a GUI in another.
Traditionally we used the Animation Control didn't we? I'm not sure but I think it runs on its own thread. Then there's the WebBrowser control which can be used "chromeless" displaying an animated GIF.
Even Windows Movie Maker can be used to convert an animated GIF to an AVI though it might have limitations in that regard. Seems like you could easily make a barber pole, "Cylon's Eye," column of falling pixie dust, or any other "I'm busy" indicator you want if the Hourglass Cursor isn't good enough.
Cody Gray's marquee style ProgressBar was a great suggestion though.

VB 6: How many controls can I have on a single form?

I know the limit for named controls is 254, beyond that you have to use control arrays. But it seems we have hit the limit for arrays too. Any idea what that absolute limit is?
There is no absolute limit. If you put enough controls on the form, you'll eventually run out of memory. I made a test app that loads command buttons into a control array. My first run stopped with an "Out of memory" error at around 6900 buttons. I shut down a few other apps and was able to load nearly 8200. I did the same thing with text boxes and got different results (about 7300 before and 8600 after). Different controls consume different amounts of memory, so there really is no way to specify an exact number of controls that you can put on a form.
We have a records management system written in VB6 and there is a UI guideline that says each record should have exactly one data entry form associated with it (i.e. can't open up other windows). As a result of this policy, one of the more complex record types in our system now has a form with a total of 659 individual controls. We had run into the 256 named controls limit, and then converted many of the controls to control arrays over time. Recently, we squeezed room for 5 or 6 new controls, after going through the entire form and converting the few remaining standalone controls to control arrays.
This is one time where I would like to break the rules, but that would involve quite a bit of refactoring to use a multiple form approach.
In any event, you can fit at least 659 controls on a form, but I've never been able to find out what the true absolute limit is (and I'm not sure that I want to).

MFC Dynamic Text Control?

What MFC control should I use and how should I use it to display constantly changing text (like progress text) on a dialog?
For example, should I use the static text control? But can you change it programmatically?
Yes, you can change the contents of a static control programmatically. Change the ID to something other than IDC_STATIC, then you can assign a member variable to it. You can set the text with your_var.SetWindowText().
Edit: how many changes are you making, and how fast? I did a quick test program with a timer (set to a duration of 0) that formats and writes a new string to the control when the time fires, so it's updating constantly. Here's what it looks like after running for a while:
And here's what Task Manager shows:
The spike a the right is (at least mostly) from taking the screen shot of the test program saving it, and so on. As soon as I quit doing things like that, CPU usage went back to do noise level (with the occasional blip). I left the program running -- a half hour or so later, it's still doing fine, with no noticeable CPU usage (in fast according to Task Manager, it hasn't used even one second of CPU time yet).

How can I customize my Visual Studio panels to take less screenspace?

I'm using VS 2008 and I notice a lot of wasted screenspace, such as the Error List upgrade I propose below. Is there any way to change the way panels are rendered to make them smaller? Or maybe some addon to VS that does what it does but with compacted panels.
Current Error List - Only 2 errors visible
Future - 6 errors visible in same space
I don't know how to customize panels the way you're asking, but I've found my own way of dealing with panels I don't need all the time.
I keep panels like errors, search results or output set to Auto-Hide. That way they can take up a pretty decent amount of space when I want to see the lists, but they're not visible at all the rest of the time. Works well for me. When I'm not using one of those panels the only windows that are visible are the solution explorer and the code editor.
If you can afford more monitors, get them. You won't have to worry about auto-hide and you'll have enough room for it all.

Resources