Important alert: (current site time 7/16/2013 1:03:04 AM EDT)
 

VB icon

Add Debug.Print to your app easy

Email
Submitted on: 3/29/2001 12:58:36 PM
By: ~:. Jeff 'Capes' .:~  
Level: Beginner
User Rating: By 7 Users
Compatibility: VB 4.0 (32-bit), VB 5.0, VB 6.0
Views: 22046
 
     The Debug.Print is most important as long as your program runs! If there is something wrong, error/problem, the user can always report to you what he did, by showing you the debugtext. BUT when it's compiled the user of your app. can't see the Debug.Print window!!! The thing I add (always) into my program is showed beneeth here following (simple but efficient):
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
'**************************************
' Name: Add Debug.Print to your app easy
' Description:The Debug.Print is most important as long as your program runs! If there is something wrong, error/problem, the user can always report to you what he did, by showing you the debugtext. BUT when it's compiled the user of your app. can't see the Debug.Print window!!! The thing I add (always) into my program is showed beneeth here following (simple but efficient): 
' By: ~:. Jeff 'Capes' .:~
'
'This code is copyrighted and has' limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=22008&lngWId=1'for details.'**************************************

1. make a Form called frmDebug
2. add a textbox called txtDebug (multiline+scrollbar(s))
3. Add a Module and Copy this into the module:
Option Explicit
Public ShowDebugWindow As Boolean
Public Function DebugPrint(DebugStr As String)
 If ShowDebugWindow = True Then
 frmDebug.Show
 frmDebug.txtDebug = frmDebug.txtDebug & vbCrLf & "[" & Time & "] " & DebugStr
 Else
 frmDebug.Hide
 End If
End Function
For those who read this but don't understand what to do exactly: 
1. Add a Form to the project (Form1)
2. Add a button into Form1
3. (Click) Code for the button is:
Private Sub Command1_Click()
ShowDebugWindow = True
DebugPrint "Button clicked!"
End Sub
when you run yer program (startup object is Form1) press the button and the DebugWindow will popup!
Good Luck!
http://start.at/iseekyou


Other 3 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments
3/29/2001 2:54:45 PMgerry mc donnell

i dont see any use for this.
unless u can print the line# of code or procedure where there is a problem. so as when u view the source u cna find where the problem is.
maybe you could add that?
(If this comment was disrespectful, please report it.)

 
3/29/2001 10:23:19 PMJay L. Bray

I use the same sort of thing in my projects. When you have a complex program like a napster client using winsock api, it's always easier to follow program flow when you use multiple listboxes to monitor various routines...

(If this comment was disrespectful, please report it.)

 
3/30/2001 11:14:22 PMChris H

This isnt bad (good for beginers) but remember to use things like the Erl Object (its for line numbers).

EX:
On Error GoTo ER

1 txtTest="Test"
2 debug.print 1/0

Exit Sub'Err=0
ER:
Debug.print Err.description,Erl,Err.number

This will simply you SEARCH for a particularly Painful LINE of code.

Now Myself i wrote an utility that line numbers for me, and thats what i use, but you dont have to number every line, you can just number PROBLEM areas? know what i mean.

If you want to see an EXCELLENT Error handler DLL (Mines :O) HEHE

Search for EttsErrHandler

Keep Coding Boys!
(If this comment was disrespectful, please report it.)

 
3/5/2002 4:04:25 PMDiado

I just use log files which log the beginning and end of every function / sub and any errors which occur within the sub, so much easier.
(If this comment was disrespectful, please report it.)

 
9/25/2003 11:14:29 AM

Nice piece of code will give it a try and let you know but it is helpful
(If this comment was disrespectful, please report it.)

 
1/9/2004 8:17:29 AMSaurabh Gupta

Get a DBMon application written in VB from here: http://www.kodeit.org/articles/art1/default.htm
(If this comment was disrespectful, please report it.)

 
3/10/2005 6:51:08 AM_Merlin_

I use something of the kind too. As for the comments above about the error line etc... That information can allways be passed to the debugwindow just like any other information you wish to be displayed in the textbox.
This is just a simple example of how to get around the debug.print problem with compiled progs. The author never stated this to be a complete sollution.
Which would of course have been better, but ...

Merlin is the name, and logic is my game...
(If this comment was disrespectful, please report it.)

 
3/11/2005 10:55:44 PMBroken Arrow

Use MZTools & insert error handlers with a single mouse click, customize the error prompt forever, you never need anything else.
(If this comment was disrespectful, please report it.)

 
12/12/2008 4:10:13 AManilkumarL

hai
(If this comment was disrespectful, please report it.)

 
12/31/2008 1:37:01 PMjaccob

nice code.
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.