dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: Visual Basic
Expertise: Intermediate
Oct 29, 1999

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


Debug Print in an EXE

Contrary to common belief, Debug.Print statements are not always removed from an executable. This behavior can be demonstrated easily. Open a new project, place a single CommandButton on the default form, and add this code:
 
Public Function DebugTime()
	MsgBox "Caught!"
End Function

Private Sub Command1_Click()
	Debug.Print DebugTime
End Sub
Compile the program to an EXE, run, and click on the button. Unexpectedly, the message box appears. This is obviously a contrived example, but it's easy to imagine cases where Debug.Print is used to print the return value of a function, for example. If variables are passed as ByRef parameters, and if the function alters the value of those variables, this error is propagated through to the executable, and might be extremely difficult to find. The morals of this tip are:
1. Pass parameters ByVal unless you're certain you're not going to change them, or you're using them as "output" parameters.
2. Be careful when using Debug.Print. It might be doing more than you think.
John Cullen
 
Comment and Contribute

 

 

 

 

 


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

 

 

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