Home > Articles > Programming > Windows Programming

  • Print
  • + Share This
From the author of

Why the Change?

Why did Microsoft make such a fundamental shift in the way arguments are passed to procedures? I think it's because it wanted to bring Visual Basic more in line with other OOP languages in which encapsulation at the procedure level is the norm. Those of us who have watched Visual Basic evolve from version 1.0 to its present fully compliant OOP state have seen the gulf between Visual Basic and other OOP languages narrow dramatically. Is there anyone on the planet who wonders where the Select Case construct came from? Was it just an off-handed decision to drop user-defined data types and replace them with the Structure keyword? I doubt it.

Microsoft has done all of us Visual Basic programmers a rather large favor by tidying up a few nettlesome details that existed in earlier versions of the language. The default behavior for procedure arguments is just one of them. By understanding what lvalues and rvalues are all about, you should also have a better understanding of how to properly use the ByVal and ByRef keywords in your programs. It should also help you to debug your code and better understand the code that VBN automatically generates for you.

By letting you decide which keyword to use in an argument list, VBN gives you the flexibility to write the code the way you want. But with that flexibility comes additional responsibility to understand fully what VBN is doing "under the hood." Being able to alter whether a procedure receives the lvalue or the rvalue of a data item gives you the power to shoot yourself in the foot several different ways. However, an appreciation of what lvalues and rvalues are all about and how they relate to procedure arguments should make your foot a little more bullet-proof.

  • + Share This
  • 🔖 Save To Your Account