954,184 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Preprocessor directives

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?

BlackDice
Light Poster
43 posts since Apr 2004
Reputation Points: 19
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You