I doubt this, but Is there a command to clear the Emmediate Window?
Printable View
I doubt this, but Is there a command to clear the Emmediate Window?
i have seen some Add Ins to do this
Many add-ins like MZ-Tools can do it :) (it's even free for VB6) :D yey!
Here's a source code of VB Helper add-in that can also do it ;)
Thanks guys but I should have been more specific, as I want to do this in code. Will MZTools provide me with that?
No, it's not possible while the program is running. If you think about that it makes sense because the Immediate window is a part of the IDE.
Yeah, I figured as much but I had to ask.Quote:
Originally Posted by MartinLiss
Thanks Martin.
If there are any members using MZTOOLS I would like to hear what they think of it.Quote:
Originally Posted by gavio
Thanks.
I think the immediate window only holds 255 lines at a time, so if you Debug.Print 255 times anything before it is wiped out.
Dim i As Integer
Debug.Print "hello world"
For i = 1 To 255
Debug.Print
Next i
Thanks for the tip. I discovered the 255 limit last week while debugging a loop.Quote:
Originally Posted by Edgemeal
FYI I have two things that may help with debugging, one is a tutorial I wrote on the subject and the other is an add-in that you can use to add the name of all (or a subset) of procedures as a constant that you can use in error handling routines or as part of a debug.print <procedure name> that you can use to supplement what you find in the call stack. You'll find links to both in my signature.
Thanks Martin, I'll check it out.Quote:
Originally Posted by MartinLiss
My 1st post already said everything - i can't do anything in VB wihtouth MZ-Tools :)Quote:
Originally Posted by CDRIVE
OK, that's clear enough.Quote:
Originally Posted by gavio
Thanks
BTW, I tried this concept by using Debug.Print VbBack hoping that it would back space over whatever was there but no go.Quote:
Originally Posted by Edgemeal
Code:
Option Explicit
Private Sub Form_Load()
Dim i%
For i% = 1 To 100
Debug.Print i%
Next i%
For i% = 1 To 100
Debug.Print vbBack
Next i%
End Sub
There is something about the Immediate window that makes it impossible to send messages to it, i'm not sure what it is, maybe the fact that it gets disabled permanently. I've got to the point that.. if you place the cursor at the end of a line, the chars in that line get deleted, but i just can't delete all the lines, even if you add the calls to postmessage inside a for loop, or if CONTROL-A is sent first to select all, no wey to delete everything in just one call, a loop will work just if it's run with F8 (running code line by line), else the messages are not posted or the window gets disabled.
For clearing just 1 line (current line)..
Code:Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
(ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, _
ByVal lpsz2 As String) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" _
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
ByVal lParam As Long) As Long
Private Const WM_ACTIVATE As Long = &H6
Private Const WM_KEYDOWN As Long = &H100
Private Sub Command1_Click()
Dim lWinVB As Long, lWinEmmediate As Long
lWinVB = FindWindow("wndclass_desked_gsk", vbNullString)
'your Inmediate window caption as last param, depends on languages..
lWinEmmediate = FindWindowEx(lWinVB, ByVal 0&, "VbaWindow", "Inmediate")
PostMessage lWinEmmediate, WM_ACTIVATE, 1, 0&
PostMessage lWinEmmediate, WM_KEYDOWN, vbKeyBack, 0&
End Sub
jcis, thank you for the code and your experiences with the immediate window. MS really missed the boat when they didn't include:
Code:Immediate.Cls
you can do in vb.net
i was trying before, using postmessage, but it crashed vb every time so not much help
also findwindowex window class is different if immediate window is /in not docked
Since we can't delete the text in the Immediate window when VB6 is running, why not just pause it for a second , del text, and run again?
Here's a basic (working) idea..
EDIT This only seems to work if the Immediate window is not docked!
Code:' ModClearImmediate.Bas
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function SetActiveWindow Lib "user32" (ByVal hwnd As Long) As Long
Public Sub ClearImmediate()
Dim Parnt As Long
Dim Imm As Long
' Get handle to Immediate window
Imm = FindWindow("DockingView", "Immediate")
If Imm Then
Parnt = GetParent(Imm) ' get parent (VB6 IDE)
SetActiveWindow Parnt ' set VB6 IDE as active window
SendKeys "^({BREAK})" ' pause VB6 IDE
SetActiveWindow Imm ' set Immediate window active
SendKeys "^({Home})" ' select all text
SendKeys "^(+({End}))"
SendKeys "{Del}" ' delete
SendKeys "{F5}" ' Run VB6 IDE
End If
End Sub