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.
- Dim oIE
- Sub Debug(strText)
- 'HOW TO USE:
- ' –> Debug("This is the text")
- ' This will display "this is the text" in a debug window
- 'uncomment the next line to turn off debugging
- 'Exit Sub
- If Not IsObject(oIE) Then
- Set oIE = CreateObject("InternetExplorer.Application")
- oIE.Navigate "about:blank"
- oIE.Visible = True
- oIE.ToolBar = False
- oIE.Width = 200
- oIE.Height = 300
- oIE.Left = 10
- oIE.Top = 10
- Do While oIE.Busy
- WScript.Sleep 100
- Loop
- oIE.Document.Body.InnerHTML = "" & Now & "
"
- End If
- oIE.Document.Body.InnerHTML = _
- oIE.Document.Body.InnerHTML & strText & "
" & VbCrLf
- End Sub
Tags: debug, debugging, ie, internet explorer, VBScript Scripts










