Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Visual Basic
Expertise: Beginner
Feb 3, 1999



Full Text Search: The Key to Better Natural Language Queries for NoSQL in Node.js

Include Code for Debugging

VB supports conditional compilation, just like Visual C++. However, Visual C++ has a predefined constant named _DEBUG that makes it easy to include code only while debugging, as in this code:
#ifdef _DEBUG
	MessageBox(NULL,"Begin Procedure", _
		"Debug Message",MB_OK);
In VB, you can do the same thing, but you need to declare the variable in the Conditional Compilation Arguments fields in the Make tab of the Project properties dialog, then remember to remove it before shipping the executable. Using the Debug.Assert command is an easier way to have statements executed only while debugging and not when running a compiled program.

For example, this line displays a message box only when running the program in the design environment and not in a compiled program:

Debug.Assert MsgBox("Begin Form_Load")
This happens because Debug.Assert works only in the design environment. To evaluate the assertion, VB executes the statement. However, when you compile the program, the compiler removes this line from the executable.
Jose Mojica
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date