Questions tagged [rubberduck]
Rubberduck is an open-source COM add-in project for the VBA/VB6 IDE written in C#. Use this tag for reviews of the C# source code, or for reviews of VBA/VB6 client code.
100
questions
14
votes
1
answer
1k
views
Low Level VBA Hacking - making Private functions Public
NEW: Download demo files
Not sure what to title this - essentially, inspired by RubberDuck's unit test engine, I've created a way to call private methods of standard modules in VBA. It also lets you ...
5
votes
1
answer
94
views
Produce date range string from a database table
My project creates a report based on test results which are stored in database table associated with a JobNumber. The test results for a particular JobNumber may be ...
3
votes
1
answer
608
views
Rigorously checking whether 2 floating point numbers are close in VBA
latest updated version in cross-post from SO
I'm testing performance regression of some code I wrote (this is not that code) by timing its execution in Unit tests. I would like to see if execution ...
5
votes
1
answer
139
views
Copy Columns Forward Macro: From Procedural to OOP
Background: I had created a macro few years ago and when I was reviewing this now, it was hard to understand.
I recently went through all the articles from ...
4
votes
0
answers
273
views
Export/Import Rubberduck VBA Virtual Folder Structure with Library References to/from Project Folder on Hard Drive
Rubberduck VBA permits creation of virtual project hierarchy within the IDE, but the project is imported/exported as a single folder with all files. Sometimes, direct access to the project folder is ...
11
votes
0
answers
355
views
Host-Agnostic Model-View-ViewModel Infrastructure
I've written an API that unlocks some serious MVVM capabilities with VBA's MSForms UI framework.
This is the complete code-behind for an example ...
7
votes
1
answer
355
views
Add Default Rubberduck VBA Folder Annotation to VBProject.VBComponents
Currently Rubberduck VBA files all the VBProject VBComponents in that do not have a Folder Annotation in a Folder named after the VBProject. It can be time consuming to manually organize the ...
11
votes
3
answers
363
views
Secure ADODB: Unit of Work
I've been meaning to revisit this old code for a long time, and this week finally ended up doing it. The resulting code is on GitHub, and for full context and disclosure I wrote a blog article about ...
1
vote
0
answers
141
views
Managing Excel Tables (ListObjects) with OOP Approach (Second follow up)
This is a follow up to this question and this question
Objective:
Manage what happens when users interact with Excel Tables (ListObjects)
Code incorporates:
...
4
votes
1
answer
798
views
Implementing a class hierarchy and instancing the base class in VBA
Objective:
Have a single point of entrance to initialize a class that holds instances of "sub" classes
Background:
I read about inheritance in VBA (or as close ...
3
votes
1
answer
770
views
Managing Excel Tables (ListObjects) with OOP Approach (Follow up)
This is a follow up to this question
Objective:
Manage what happens when users interact with Excel Tables (ListObjects)
Code incorporates:
Greedo's answer suggestions:
Listen to an encapsulated <...
5
votes
1
answer
624
views
Managing Excel Tables (ListObjects) with OOP Approach
Objective:
Manage what happens when users interact with Excel Tables (ListObjects)
Possible interactions:
Update an existing Excel table
Add rows/columns to the table
Update a cell or a range of ...
6
votes
2
answers
327
views
Create a 2 way mapping to allow you to stringify enums or map one enum to another
I've created a class that creates key->value pairs but also value->key pairs - i.e. a reversible hash-map. This is because I want to be able to switch between corresponding members of 2 enums ...
4
votes
1
answer
297
views
OOP Dependency inversion principle VBA
I've reproduced the example of this video where dependency inversion principle is explained by Tim Corey based on C#
I had some trouble understanding the scope of the Logger and MessageSender ...
14
votes
1
answer
1k
views
Tick. Tick. *breathe* BOOM! - Setting up real, stable asynchronous callbacks with WinAPI Timers in VBA
WinAPI Timers can be quite tricky to work with, as anyone who's tried to use them and fallen foul of one of the many pitfalls probably knows. Problems such as screen freezing, crashes, uncontrolled ...
3
votes
0
answers
150
views
Rich data types - boolean object
Context
You can probably skim most of this, it's unlikely to be useful for a review and is just for background info. Also download the files
I've tried to create a ...
5
votes
1
answer
257
views
Custom lexer/parser-based code prettifier
I'm adding rather extensive xml-doc comments to all Rubberduck inspection classes, like this:
...
3
votes
2
answers
122
views
Abstracting and unit testing lookups in Excel table
Background
I have a vba solution that I use to ingest investment text reports and reformat them for analysis in Excel. It works, but the macros involve a lot of direct manipulation of Excel objects, ...
3
votes
0
answers
146
views
Unit testing a custom collection
To enable unit testing in the VBA IDE I'm using https://github.com/rubberduck-vba/Rubberduck.
I've created a class and a custom collection class to work with structural members I need to filter. The ...
10
votes
2
answers
173
views
Prettifier isn't pretty
Some context
I'm implementing a self-closing pairs auto-completion feature in Rubberduck. One of the challenges is that the VBIDE API doesn't allow editing a line of code by "injecting" characters: ...
12
votes
1
answer
376
views
BattleShip Grid: Classes and Tests
In my ongoing quest to demonstrate how VBA code can absolutely be object-oriented, I've started implementing a game of Battleship in pure VBA.
This is a rather large project, so I'll split the ...
15
votes
2
answers
387
views
Enhancing autocompletion for VBA code
Context
The Visual Basic Editor (VBE) does a good job at completing member scopes, for example when you type this and hit ENTER...
Private Sub DoSomething
You ...
3
votes
0
answers
628
views
Maintaining a complicated installer supporting per-user and everyone
Another challenge for developing rubberduck VBA project is to develop an installer that support per-user mode and everyone-mode.
Normally with an MSI package, one has a bootstrapper so it is possible ...
11
votes
1
answer
3k
views
Using build event to run Powershell script to run built DLL
As a rule, whenever I find myself doing something that nobody else is doing, I have to be quite suspicious about what I'm doing. This is why I want to get code review to verify I'm not doing something ...
12
votes
4
answers
618
views
Constructor-injecting a truckload of commands
There's a problem in Rubberduck that we haven't neatly solved yet, and as we're exploring alternative approaches I figured I'd ask the CR community and see what our C# experts think.
Here's the ...
5
votes
1
answer
1k
views
Antlr Visitor with complex result
I'm currently helping out on Rubberduck open source project, specifically on the Extract Method functionality.
I wrote a purpose-built visitor to assist with ...
6
votes
3
answers
205
views
Rubberduck Test Module Creation
I recently started learning C# and am taking the opportunity to try and accelerate my introduction by helping the RubberDuck team (Website and GitHub Repo). The full class code that I'm working on can ...
11
votes
1
answer
202
views
Properly destroying the VBE
The disposable wrappers worked exactly as intended... and that turned out being a huge mistake:
That's because the .net runtime creates a Runtime Callable Wrapper per-type, not per-instance*; it took ...
7
votes
2
answers
448
views
A generic IEnumerator to enumerate COM collections
As I wrapped the VBIDE API, I encountered a number of "collection types" (Windows, CodePanes, ...
9
votes
3
answers
2k
views
Wrapping COM objects with IDisposable
One of the things believed to contribute to destabilizing Rubberduck 2.x, is the fact that a lot of COM object references are stored in many places, and ...
3
votes
1
answer
116
views
ApplicationSettings Class for disabling/restoring Application State
This previous iteration of this question can be found here
A utility class to handle the state of the Application object.
Storing the application's initial state (...
4
votes
1
answer
309
views
IDTExtensibility2 implementation for Rubberduck's entry point
Here is the new & improved Rubberduck 2.x entry point class, based on MZ-Tools 8.0's Connect.VBA implementation of the ...
3
votes
1
answer
132
views
Avoiding a call to CommandBarControl.Picture
Earlier today, I encountered an Access Violation error when opening the VBE for SolidWorks 2006, while Rubberduck VBA was initializing.
I traced the Access Violation back to an attempt to set the ...
14
votes
3
answers
198
views
Fighting f̶i̶r̶e̶ regex with f̶i̶r̶e̶ regex
So someone requested a Regex Builder / Assistant for Rubberduck and since my CS class had been covering the topic only recently I was thinking to myself: "This sounds interesting, you should do ...
4
votes
2
answers
141
views
Code Explorer UI
The third post in the Code Explorer series is about the UI and main VM.
This is the XAML, except a few hundred lines of styling:
...
4
votes
1
answer
80
views
Code Explorer View Models
Continuing the series of Code Explorer posts, here is the collection of view models for the tree nodes:
This is the interface for nodes with a declaration.
...
6
votes
1
answer
133
views
Code Explorer Commands
Rubberduck's Code Explorer was recently redesigned from scratch:
Anything from modern features, such as virtual folders (limitation of the VBE--it doesn't support real folders), to ancient features ...
7
votes
2
answers
542
views
Evaluating Parser State
The "parser state" of a module in rubberduck can be one of several values:
...
8
votes
1
answer
303
views
A status bar for the VBE
One of the most annoying things about the VBE (VBA's IDE), is that it doesn't have a status bar.
Rubberduck 2.0 works around this by introducing the ...
7
votes
2
answers
337
views
Exporting a UserForm from the VBE... and working around API bugs
Rubberduck has been using an extension method to export code files, notably for source control purposes.
While testing source control, I ran into a weird bug in the VBIDE API, which caused UserForm ...
7
votes
1
answer
506
views
Milking a COM type library: "fun" with COM reflection
Once upon a time, there was a duck that wanted to know where and how user code was calling into the VBA standard library and Excel object model. To match the rest of its API, the poor little duck had ...
4
votes
1
answer
66
views
FindAllReferencesCommand 2.0
Rubberduck 2.0 will feature a "Search Results" dockable toolwindow that will be used for displaying the results of Find all references, Find all implementations, and whatever else we need to find. It ...
5
votes
1
answer
273
views
About Window in XAML
I just redid Rubberduck's About window in XAML:
I do not like my XAML very much. The way I place the StackPanel for the white pane over two rows, only to provide ...
3
votes
3
answers
636
views
Unit Test Settings
Recently, I redesigned the Rubberduck settings pane. Here is the unit test settings view, which is posted in this question:
The part we are referring to is the section in the right pane. The rest ...
4
votes
1
answer
207
views
Displaying inspection results, grouped per user selection
The Rubberduck 2.0 Code Inspections UI was recently redesigned (again!), this time featuring a GroupingGrid control (thanks @BrunoCosta!), and what appears to be a ...
7
votes
4
answers
498
views
Unit Testing the Duck
I recently reinstated the unit tests in Rubberduck. Previously, our parser was a synchronous parser, with everything running in sequence, and we could just request a parse result. Now, however, it ...
10
votes
1
answer
294
views
Code Explorer 2.0: A folder hierarchy to organize VBA projects
Next release of Rubberduck will introduce a very cool @Folder annotation system that the Code Explorer will use to organize modules into - you guessed it - folders:
...
6
votes
1
answer
105
views
Inspector Rubberduck and the abstract inspections
The Rubberduck code inspections have just seen yet another structural change, hopefully for the better.
The IInspectionModel interface was originally named ...
5
votes
1
answer
99
views
Convert Procedure to Function
My latest inspection for Rubberduck determines whether a procedure should be a function by checking whether it has a single ByRef parameter (either explicit or ...
11
votes
1
answer
144
views
Extract Interface
One of the latest refactorings for Rubberduck is Extract Interface. This refactoring will take a class, display all public members, and allow you to select which members you wish to include in your ...