VB icon

Add Debug.Print to your app easy

Email
Submitted on: 1/16/2015 6:48:00 AM
By: ~:. Jeff ''Capes'' .:~ (from psc cd)  
Level: Beginner
User Rating: By 7 Users
Compatibility: VB 4.0 (32-bit), VB 5.0, VB 6.0
Views: 1968
 
     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!
				
'**************************************
' 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'' .:~ (from psc cd)
'**************************************

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


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


 There are no comments on this submission.
 

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.