Adam, you are skirting the "disrespect" line in the sand again. Because it is POSSIBLE that there might have been a minor level of provocation, I am not giving you a time-out. But your attitude is part of what causes folks to react to you as they do. Your direct comments are at question, but also your "asides" in post #4 and #8 are objectionable. You threw in two gratuitous remarks my way when I hadn't yet stepped in to the discussion. It happened that this time you blasted me in the asides, but you then blasted
moke123 directly in #9 and #11. When someone says "Sorry, not interested" you make a snide remark. This HAS GOT TO STOP. There is no disrespect in a statement that says "Sorry, not interested."
Now, as to the business of your lessons:
You need to be careful because you are using a variable called
return as a return value from several code sequences, but it happens that
return is also a reserved word in VBA, as an action verb meaning "go back to whatever called you." It is generally not a good idea to use reserved words as variables. In some cases, they can be "qualified" with a prefix, but in other cases they can run wild. Actually, for function returns you CAN use
return to return a value, but not using the syntax as you show it. Using
return as a variable inside a function that potentially would have a "natural"
return statement is asking for syntax trouble.
Learn more about: Return Statement (Visual Basic)
docs.microsoft.com
You also have something that for teaching purposes MIGHT be OK - but might equally be very misleading. Exercise 14 has two local variables
ReturnX and
ReturnY. You assign values to them. Then you ask their probable values
when the code finishes executing. Since you include the
End Sub as part of the demonstration code, the technically correct answer is "non-existent." You have to recognize that
End Sub is executable, too! It acts just like
Exit Sub if your code falls through to it. So when the code has finished, all locally declared variables have been dissolved and no longer exist anywhere.
Finally, if you are going to teach, then TEACH. Your style appears as though you are giving out tests that someone might try as experiments in an Access environment. My criticism is that a beginner might not know how to get to a VBA coding page, much less how to start execution of code at a selected place, to test what you have shown. When they hit the code where you are trying to demonstrate syntax errors, they will face situations of error handling, for which they could EASILY panic. You have no instructions for using that set of "lessons" and that leads to another conceptual problem. You are shooting at a mixed target - on the one hand that someone would know how to activate the code snippets you are showing, on the other that if they CAN get to that point, that they don't already know this kind of stuff. And on the third hand, that the answers to your questions require pointers to reference material. (OK, I've been re-reading my Edgar Rice Burroughs "Mars" series, where third hands are possible. And fourths as well. Thark you very much...)
Without a decent preface, explanation, or usage instructions, the proper utilization of these "lessons" is ambiguous at best and unknowable at worst. We would have to name your series
Adam's VBA Coding for Genius-Dummies.