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.

Filter by
Sorted by
Tagged with
10 votes
0 answers
169 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 ...
user avatar
  • 1,998
5 votes
1 answer
79 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 ...
user avatar
0 votes
0 answers
54 views

GUIComparer with MVVM dialog to allow user input in ArrayList sorting algorithm

download Bit of an esoteric title, but let me explain. I wanted to create an IComparer that can be supplied to a sorting algorithm, which rather than using the ...
user avatar
  • 1,998
3 votes
1 answer
167 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 ...
user avatar
  • 1,998
5 votes
1 answer
117 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 ...
user avatar
4 votes
0 answers
120 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 ...
user avatar
  • 375
11 votes
0 answers
308 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 ...
user avatar
6 votes
1 answer
212 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 ...
user avatar
  • 4,028
11 votes
3 answers
274 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 ...
user avatar
1 vote
0 answers
95 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: ...
user avatar
4 votes
1 answer
417 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 ...
user avatar
3 votes
1 answer
554 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 <...
user avatar
5 votes
1 answer
408 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 ...
user avatar
6 votes
2 answers
212 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 ...
user avatar
  • 1,998
4 votes
1 answer
185 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 ...
user avatar
13 votes
1 answer
793 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 ...
user avatar
  • 1,998
3 votes
0 answers
113 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 ...
user avatar
  • 1,998
5 votes
1 answer
187 views

Custom lexer/parser-based code prettifier

I'm adding rather extensive xml-doc comments to all Rubberduck inspection classes, like this: ...
user avatar
3 votes
2 answers
106 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, ...
user avatar
  • 51
3 votes
0 answers
116 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 ...
user avatar
  • 3,477
10 votes
2 answers
165 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: ...
user avatar
12 votes
1 answer
334 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 ...
user avatar
15 votes
2 answers
319 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 ...
user avatar
3 votes
0 answers
495 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 ...
user avatar
  • 2,009
10 votes
1 answer
2k 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 ...
user avatar
  • 2,009
12 votes
4 answers
483 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 ...
user avatar
5 votes
1 answer
817 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 ...
user avatar
  • 2,009
6 votes
3 answers
195 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 ...
user avatar
  • 3,477
11 votes
1 answer
185 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 ...
user avatar
7 votes
2 answers
413 views

A generic IEnumerator to enumerate COM collections

As I wrapped the VBIDE API, I encountered a number of "collection types" (Windows, CodePanes, ...
user avatar
9 votes
3 answers
1k 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 ...
user avatar
3 votes
1 answer
99 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 (...
user avatar
  • 8,800
4 votes
1 answer
273 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 ...
user avatar
3 votes
1 answer
110 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 ...
user avatar
  • 1,961
14 votes
3 answers
190 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 ...
user avatar
  • 25k
4 votes
2 answers
132 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: ...
user avatar
4 votes
1 answer
76 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. ...
user avatar
6 votes
1 answer
127 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 ...
user avatar
7 votes
2 answers
532 views

Evaluating Parser State

The "parser state" of a module in rubberduck can be one of several values: ...
user avatar
8 votes
1 answer
297 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 ...
user avatar
8 votes
2 answers
312 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 ...
user avatar
7 votes
1 answer
435 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 ...
user avatar
4 votes
1 answer
62 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 ...
user avatar
5 votes
1 answer
256 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 ...
user avatar
3 votes
3 answers
619 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 ...
user avatar
4 votes
1 answer
186 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 ...
user avatar
6 votes
4 answers
425 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 ...
user avatar
10 votes
1 answer
263 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: ...
user avatar
6 votes
1 answer
96 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 ...
user avatar
5 votes
1 answer
77 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 ...
user avatar