I'm trying to copy values from one sheet to another sheet if value exist, code run great on around 500 rows but very slow on 5000 rows.
I was wondering if there is any way I can speed it up my code?
Option Explicit
Public Sub FlashCycleCount()
' updating off
With Application
....
I hope I can get a wee bit of help.... I'm mocking an object. But when I access the instance of the mocked object, it returns null which then throws. What I'm missing?
public class MockVbeEvents
{
public static Mock<IVBEEvents> CreateMockVbeEvents(Mock<IVBE> vbe)
{
var result = new Mock<IVBEEvents>();
result.SetupReferenceEqualityIncludingHashCode();
return result;
}
}
[Category("Code Explorer")]
[Test]
public void AddUserForm()
{
var builder = new MockVbeBuilder();
var project = builder.ProjectBuilder("TestProject1", ProjectProtection.Unprotected)
.AddComponent("Module1", ComponentType.StandardModule, "");
var components = project.MockVBComponents;
var vbe = builder.AddProject(project.Build()).Build();
var vbeEvents = MockVbeEvents.CreateMockVbeEvents(vbe);
public RubberduckParserState(IVBE vbe, IProjectsRepository projectRepository, IDeclarationFinderFactory declarationFinderFactory, IVBEEvents vbeEvents)
{
_vbe = vbe ?? throw new ArgumentNullException(nameof(vbe));
_projectRepository = projectRepository ?? throw new ArgumentException(nameof(projectRepository));
_declarationFinderFactory = declarationFinderFactory ?? throw new ArgumentNullException(nameof(declarationFinderFactory));
_vbeEvents = _vbeEvents ?? throw new ArgumentNullException(nameof(vbeEvents));
it throws on the _vbeEvents = vbeEvents
The sad thing is that it's not even under test. I'm just satisfying the new ctor parameters....
i thought maybe because i must do a Setup but the class doesn't even have a method / properties to be setup, so I tried setting up the events but that got me farther down the rabbit hoe.
> # [Codecov](https://codecov.io/gh/rubberduck-vba/Rubberduck/pull/3823?src=pr&el=h1) Report > Merging [#3823](https://codecov.io/gh/rubberduck-vba/Rubberduck/pull/3823?src=pr&el=desc) into [next](https://codecov.io/gh/rubberduck-vba/Rubberduck/commit/7a05cc4d4a99fe8a0d514e5027fdc982edfb7ecf?src=pr&el=desc) will **decrease** coverage by `0.04%`. > The diff coverage is `22.45%`.
The key to writing clear, unambiguous code, is rather simple: Do what you say; say what you do. VBA has a number of features that make it easy to not even realize you’re writing code that doesn’t do what it says it does. One of the reasons for that, is the existence of default members – under the guise… Continue reading VBA Trap: Default Members →
@FreeMan Did you ever need to access the next element that followed an element with an ide? ...<h4 id="Foo">Foo Description</h4><p>Some text you wanted to grab</p>...
I can grab the id easy enough but the element following contains info I want to pair with Foo. I get the feeling that SeleniumBasic isn't the right fit for this.
You can't parse [X]HTML with regex. Because HTML can't be parsed by regex. Regex is not a tool that can be used to correctly parse HTML. As I have answered in HTML-and-regex questions here so many times before, the use of regex will not allow you to consume HTML. Regular expressions are a tool th...
> I’m sorry that this went unanswered for so long. We’ve removed the experimental source control feature per #3758.
You can use the “Export All” feature to export your source files to the local file system and use whichever VCS you chose. This turned out to be the simplest way for us to support as many users as possible.
> Per #3758 we’ve removed the source control feature. The “correct” workflow now would be to “Export All” to the file system, edit with VS Code, then “Import All” back into the workbook.
@contributors also a reminder to be mindful of Rubberduck’s accessibility. Please take the time to fill in UI element attributes properly.
@PeterMTaylor it might be nearing the end of it's life, if it's always at 100%. You should look into some disk health stats and consider replacing that one
@IvenBach IIRC there should be something like nextSibling in selenium
@IvenBach DOM traversal is the most robust way of doing it, hands down
if you just want to scrape stuff quickly and really dirty and probably with some errors in it, you can go for RegEx
2. You don't want the default member to return an instance of itself (or you'll crash the host at runtime and design-time - stackoverflow.com/a/42077042/5757159
4. You didn't mention the bang operator for accessing the default member and passing a string argument
5. The discussion (rather than the bug) in Issue 3153 still confuses me as to what the default member of Cells is, when using parentheses immediately after Cells. But there are some good links towards the bottom of the issue.
7. Many default members are prefixed with an underscore, but you can still call them explicitly with square brackets around the member name.
3. You can demonstrate 2 identical expressions, with different treatments, in a single collection.Add ActiveSheet.Cells(1, 1), ActiveSheet.Cells(1, 1) statement - stackoverflow.com/questions/37866303/…
@IvenBach No, I knew exactly which elements I was after. I've used it on 2 sites to log in, navigate to a download page, fill in some download parameters, click "download now", wait for the processing to finish, rename/move the DL'd file (as necessary), then log out gracefully.
after writing each process in one large module, just to figure out where I was and what I was doing, I was able to extract an Interface from that and wrote 2 implementations of it. So I'm good(ish) to go if/when we add a 3rd site.
I just uninstalled .2929 and it warned that "some elements weren't uninstalled - they can be removed manually" or something similar.
Do I need to jump through all the hoops described yesterday to unregister bits and pieces?
N.B.: I usually don't uninstall between .pre releases, despite warnings to do so, so I may have FUBAR'd myself in that department...
@Mat'sMug ah, yes, I do see that there. Since there's still a rubberduck.config that means that when I install .2947, it will pick up my existing config?
@ThunderFrame You'd mentioned something about the bang operators not being the best way to go about doing things a while back, but I've lost track of the conversation and forgotten what you'd said. Any good references to read up on that? (Or want to give a brief dissertation on the topic again?)
@this ah. no, I've done that only once. I star, then look at all stars and filter for the ones I've starred. eventually, with enough paging and Ctrl-F, I'll come across it again.
I suppose if we only starred things that were really useful (like the "don't use bangs" comment), that would be more efficient.
but it's more fun to star funny, interesting and snarky comments, too.
me neither. I usually just install over the top of the previous version (I know, it breaks the rules, hasn't bitten me yet! ;) ). This time, with all the warnings, I did an uninstall. When I reinstalled, the installer paused & warned that I had Excel open, offering to close it for me. I made sure I saved what I was working on, then TM appeared once the Excel window closed and I happened to notice it.
*TM was running, it was just at a lower Z order... it didn't magically start running itself. Just to be clear™
@this It's even more efficient to Set myField = Rd.Fields("SomeField") and then use myField.Value inside your loop.... That way you only resolve the field(s) once. I'll see if I can find the article.... Tomorrow....
@this Do you ever prefer rs.Collect("SomeField") over rs.Fields("SomeField").Value? It's supposed to be faster if you're only concerned with the values.
@ThunderFrame I don't have a use case for that, TBH. It's very rare for me to want the data in an array or something like that. More generally, I'm just using the recordset as a binding for form or dumping it into some other format (excel file, text file, a report)
but yes, I've read that it's better to use Collect if you want the values -- there is also a method in C++ for transforming the recordset into a data structure but that's not exposed in VB. It's described in the old book for hte Jet Engine's Programmer Reference.
@this Collect doesn't return an array, it just returns the field value without the overhead of the entire field object, so in theory, it is faster than setting/getting the field object's value.
if I'm looking at the code, no way in hell, i'm going to see rs.Collect("SomeField") and go "oh, yeah, I'm reading this one value at the current position"
@this Range.Value2 gets you a Currency or a Date given proper cell formatting. Otherwise you get a String or a Double, but there's no way to statically know this.
we could have the resolver "expression" pass flag variant/object expressions as such, and then have a UI tool to "manually map late-bound expression..."
then default members are still a problem though
where do you click to map an implicit call to Worksheets.Item?
so, say we right-click the "1" in Worksheets(1).Range("B22"), and RD knows we're in the arglist of an implicit member call; we could have a UI to map Worksheets.Item to the Excel.Worksheet type, and with that "manual hint/nudge" the resolver is now equipped to resolve the .Range("B22") call to a Range object
currently we get stuck on Worksheets(1) returning a Variant, and resolution ends there
once we get to the Range object, we can look at LHS and determine whether the expression is a Range (given a Set keyword) or a Variant (given an implicit default member call on Range)
Generally speaking, if you look at MSDN doc for majority of Variant-returning method, the doc will tell you it only returns a particular subtype of the Variant
Crowdsourcing this kind of data would help track whether someone is making a funny cast or not.
> There's some unit tests that check for certain bindings. We might want to expand those... We should take care to not lock ourselves into some structure though.
It's somewhat interesting that this only applies for some commands.
The Command Bindings did change in the PullRequest, relevant diff starts at [RubberduckIoCInstaller.cs#Line 525](https://github.com/rubberduck-vba/Rubberduck/pull/3739/files#diff-1d0ced34d32061d419523ca7feaeda97L525)
@Mat'sMug we can't really have users push that to a webservice. After all if we could automatically determine it, we don't need to specially maintain it
TBH as much as the original grammar was helpful, the current one has little to do with it. I wonder if it can even be called a derivative, given the rewrite it went through
Any Kiwis seriously planning to attend should contact Liam Bastick this morning at liam.bastick@sumproduct.com https://twitter.com/PeltierTech/status/974288092579467266