• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2933
  • Last Modified:

vb6: Programatically Clear Immediate Window

That's it.  How do you clear the Immediate Window from code?  I can debug.print to it all day long, but I want to be able to clear it from time to time.  Did Microsoft provide us with a feature to do this?

Thanks,

Lankford
0
lankford
Asked:
lankford
  • 8
  • 3
  • 3
  • +7
1 Solution
 
caraf_gCommented:
Good question, I've often wondered why there is no debug.clear method.

Hope you don't mind I hitch a ride on this one ;-)
0
 
lehketCommented:
Well . . . what I always do is periodically select all the text and hit the delete key.  But I assume that's not the answer you're looking for.  There might be a way to do it by subclassing the IDE, but that's something I haven't done anything with myself so far.
0
 
mcriderCommented:
This question has been asked a couple of times, and no one has come up with a good answer...

The hoaky solution I've seen posted here is:

for i=1 to 200
   debug.print VbCrLF
next i


That doesn't clear the window, but it will give the "appearance" of an empty window...


Lame huh?
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
deightonCommented:
                   Public Sub ClearDebug()
                   

                       Dim pWindow As VBIDE.Window
                       
              Set pWindow = VBInstance.Windows("Immediate")
                       
                       If pWindow Is Nothing Then Exit Sub
                       
                       If pWindow.Visible = True Then
                          pWindow.SetFocus
                          SendKeys ("^({Home})"), True
                          SendKeys ("^(+({End}))"), True
                          SendKeys ("{Del}"), True
                       End If
                       Set pWindow = Nothing

                    End Sub
0
 
vettrangerCommented:
Nicely done, Deighton :-)
0
 
Erick37Commented:
Making it an Add-In will keep it out of your code.
0
 
mcriderCommented:
deighton,

What reference do you have to add in to get "Dim pWindow As VBIDE.Window" to work?

Cheers!
0
 
deightonCommented:
0
 
vettrangerCommented:
no shame deighton, its not "What you know", but "Who you know" LOL
0
 
lankfordAuthor Commented:
All right.  I'm totally confused now.  What are we saying here people?  You have to have Waty's add-in in order to do this.  I downloaded/installed the add-in but all I get is a button that perfoms this function in design mode.  How do you call this function from your code?  Can you?

lankford (dazed and confused)
0
 
lankfordAuthor Commented:
I just saw Eric's response.  I am rejecting this answer because you apparently can't call it from code.

So far, mcrider is the closest!

lankford
0
 
mcriderCommented:
deighton,
 
So there is no reference to add?? or this only works on VB6?

Cheers!

0
 
LorenGCommented:
You need to add a reference to VB6 Extensibility
0
 
mcriderCommented:
I can't get it to work with VB5 Extensibility...
0
 
DrDelphiCommented:
The "hoaky" and "lame" answer is also a valid one, kiddies. The debug window has a limit on the number of lines it contains. Filling it with empty lines does not just give the appearance of clearing it, it actually does. Empty strings replace populated ones.... out with the old , in the new. <G>

0
 
lankfordAuthor Commented:
mdrider,

In the interest of closing out this topic, convert your comment into an answer and I'll award you the points.

lankford
0
 
mcriderCommented:
thanks!
0
 
mcriderCommented:
DrDelphi,

By the way, it doesn't work if the last cursor position of the immediate window is at the top of the window...

Cheers!
0
 
DrDelphiCommented:
McRider,
  If the cursor position is at the top of the window, what are you trying to clear? <G>
0
 
mcriderCommented:
DrDelphi,

Ok, your program puts 60 or so lines in the debug box... your Immediate window has been sized to show about 10 lines at a time... You focus in the Immediate window with your cursor and use the arrow keys or PageUP keys to scroll up to the top of the immediate window to see the 1st 10 lines your program put there.

Then you want to clear the window... Run the code and see what happens...

Cheers!
0
 
mcriderCommented:
Thanks for the points!
0
 
SiM99Commented:
This message is for mcrider more than anyone......

I found something that clears the immediate window for you ..
a VB Pligin (with source)

i've not tested it yet though

What was the other message we were trying to do this in mcrider ?

Here's the URL : http://vbcode.com/asp/showzip.asp?ZipFile=http://www.vbcode.com/code/Clearlmm.zip&theID=736
0

Featured Post

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

  • 8
  • 3
  • 3
  • +7
Tackle projects and never again get stuck behind a technical roadblock.
Join Now