Browse CLASSROOM TRAINING REGISTER for classroom training CONTACT us

SAPIEN Solutions

SAPIEN homepage
PrimalScript script editor+ide
PrimalScope script debugger
Free Tools script utilities
SAPIEN Press tech books
ScriptingAnswers.com learn+share
ScriptingOutpost.com online store
Blog.Sapien.com official blog
Contact Us

 

A VBScript Debug Window

 This is one of my favorite tricks for debugging. Rather than adding MsgBox() calls to display variables’ contents, I write them to a separate IE window. When I’m done debugging, I uncomment one line (as noted below) to disable the debugging functionality - which is easier than going through and removing all the statements manually, plus it leaves them in there for future use, if needed.

  1. Dim oIE
  2. Sub Debug(strText)

  3. 'HOW TO USE:
  4. ' –> Debug("This is the text")
  5. ' This will display "this is the text" in a debug window

  6. 'uncomment the next line to turn off debugging
  7. 'Exit Sub

  8. If Not IsObject(oIE) Then
  9. Set oIE = CreateObject("InternetExplorer.Application")
  10. oIE.Navigate "about:blank"
  11. oIE.Visible = True
  12. oIE.ToolBar = False
  13. oIE.Width = 200
  14. oIE.Height = 300
  15. oIE.Left = 10
  16. oIE.Top = 10
  17. Do While oIE.Busy
  18. WScript.Sleep 100
  19. Loop
  20. oIE.Document.Body.InnerHTML = "" & Now & "
    "
  21. End If
  22. oIE.Document.Body.InnerHTML = _
  23. oIE.Document.Body.InnerHTML & strText & "
    " & VbCrLf
  24. End Sub
[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Tags: , , , ,

Leave a Reply


Entries (RSS) and Comments (RSS).