The incorrect use of ByRef
Just the thing to avoid.
Of course, I've never encountered any such thing in my code. ;-)
But this is just my personal approach, if you only use ByRef and always make sure that parameter values are never changed, then of course this is correct.
Very interesting examples.
That's the thing: It's perfectly valid or correct to have a style preference for one or the other, but only if one pays deliberate attention to the consequences. If one does, no worries, but one must.
ByRef clearly carries more risk. As much as I might prefer it as a default, I wouldn't if I weren't in the habit of being deliberate and express with each declaration, and deliberately aware of how a procedure acts with or upon each reference.
Perhaps this is also due to the fact that I also program a lot with C#.
I expect that explains a great deal. I don't work with C# but fiddle with VB.NET and Win32 enough to understand that the prospects of passing an argument out of process are such as to require ByVal not just as default but practically as a matter of course. Access isn't even threaded, so it's a different ball game.
For me, this is worth more than the time that may be needed to create a copy of the reference.
Overall, a very interesting and thoughtful post, and thanks. I'll be giving it a few more close reads.
Honestly, I never understood why classes are often considered complicated. For me, they're just a regular part of working with VBA.
From experience, I can say that the notion of instantiation is a significant conceptual leap for those without formal CS training. They don't know what they don't know. The bigger problem, however, is that those who do understand the topic quite often don't, either, and so are incapable of explaining it.
I've had this discussion with other senior Access developers, but moving,
e.g., from Excel to Access without such training requires crossing not one, but two conceptual chasms, apart from gaining some proficiency with VBA and SQL. Once I explain, those developers' reactions consistently has been recognition and astonishment that they hadn't grasped how little of their foundational knowledge was commonly held.
The first, and easier of the two chasms to cross, is what I call the "back-end" chasm, normalization. Chiefly because their experience is limited to two-, or perhaps three-, dimensional representations in worksheets and workbooks, many have difficulty conceptualizing normalization and table relationships. Many never get it, and struggle even with the native lookup functions.
To your point, the second and more difficult conceptual chasm to cross, what I call the "front-end" chasm, is instantiation.
E.g., it will come as a complete surprise to someone accustomed to data residing on/in a spreadsheet, to learn that they can use the same subform on three different main forms simultaneously. Then, advancing from programming forms and controls with anything more than macros and filling out property sheets, to meaningful VBA, is another step. Going further, VBA lets one gloss over or even ignore many of the basics of declarations, pointers, and scope when simply programming forms and controls. Programming classes is impossible, however, without a far deeper and more fundamental grasp of these concepts, their interaction, and event progression because the task then includes memory management. Over time and with practice, one can keep more of these balls in the air but recognize that neither the topic nor many of its constituent elements are necessarily even apparent to virtually anyone, and when they are, not fully understood.
To give you an idea, I have two postgraduate degrees, one of which fairly quantitative but neither of which involved CS or required any programming, from places most people have heard of. In school and at work, I became a power user in 123, WordPerfect, Approach, Excel, etc. and yet never encountered even the concept of a development environment. Write code? Great! Where? Then, what? Literally. Bad enough that I had to, but far worse that anyone might think I would, could, or even had the first idea where to start. Then, IBM orphaned Lotus Approach and I was compelled to embrace Access. I got started and now, years later, am informally editing others' book drafts on the topic by invitation, giving an occasional developer presentation, and realize the VBE is a shell.
Get to a certain level and it's easy. Just like playing Chopin, or Brubeck.