BlackDice 4 Light Poster

Is there a way in VB to use a '#define' macro something like in c++? In C++ I can do this:

#define CHECKPTR if(!ptr) AfxMessageBox("Pointer is null");

then everywhere I wanted to do that check, (of course the pointer would always have to be named 'ptr'), I could just write this:

ptr = new CSomePointer;
CHECKPTR

the preprocessor actually expands the text in the appropriate places before compiling the code, so I don't have to have that same code everywhere. Is there a way to do this in VB?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.