ByRef v ByVal
By Richard Rost 4 years ago
ByRef v ByVal in VBA. Creating an Increment Operator.
If you're familiar with languages like C there is an increment operator. To increase the value of X all you have to do is write X++ whereas in VB you have to say X=X+1. That doesn't seem like a lot of extra work, unless you have a long variable name like "CustomerStatementCounter" or something like that. So, wouldn't it be nice to create our own increment operator so all we have to say in our code is Inc X and that's it. That's what this lesson covers, and to do it, I'll teach you the different between ByRef and ByVal variable calls in our subs and functions.
Alex from England (Admin) asks, "After watching yesterday’s Extended Cut video, you mentioned that Access VBA doesn’t have an Increment Operator like C does which is ++. Does it support +="
I'll show you how to use optional parameters, use our increment sub with a form field instead of just a variable, determine if a value is numeric, and create a public global subroutine or function.
Silver Members and up get access to view Extended Cut videos, when available. Gold Members can download the database template from class plus get access to the Code Vault. If you signed up on YouTube you have to register on my YouTube Find User page so I can set up your account here on my web site. If you're not a member, Join Today!
Subscribe to ByRef v ByVal
Get notifications when this page is updated