Beware of Defxxx directives

Beware of Defxxx directives

Every now and then I see DefInt or DefLng directives spread over Visual Basic code modules, whose intended purpose is to revert the default data type from Variant to Integer or Long. I don’t encourage using this directive, because it makes all the procedures in the module dependent of something that is placed outside them. In other words, you don’t have self-sufficient and encapsulated procedures anymore.

You see the perverse effect of this when you move the procedure to another module or project that has a different Defxxx directive, or has no such directive at all. All of a sudden, your carefully tested procedures aren’t working as they used to do, but you’re the one to blame.

See also  How to Create and Deploy QR Codes Online: A Comprehensive Guide

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist