VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Add Debug.Print to your app easy

by ~:. Jeff 'Capes' .:~ ()
Category: Debugging and Error Handling
Compatability: Visual Basic 3.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (7 Votes)

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):

Rate Add Debug.Print to your app easy


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

Download this snippet    Add to My Saved Code

Add Debug.Print to your app easy Comments

No comments have been posted about Add Debug.Print to your app easy. Why not be the first to post a comment about Add Debug.Print to your app easy.

Post your comment

Subject:
Message:
0/1000 characters