Results 1 to 18 of 18

Thread: Clear Emmediate Window

  1. #1

    Thread Starter
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

    Clear Emmediate Window

    I doubt this, but Is there a command to clear the Emmediate Window?
    <--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
    If topic has been resolved, please pull down the Thread Tools & mark it Resolved.


    Is VB consuming your life, and is that a bad thing??

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Clear Emmediate Window

    i have seen some Add Ins to do this
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

  4. #4

    Thread Starter
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

    Re: Clear Emmediate Window

    Thanks guys but I should have been more specific, as I want to do this in code. Will MZTools provide me with that?
    <--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
    If topic has been resolved, please pull down the Thread Tools & mark it Resolved.


    Is VB consuming your life, and is that a bad thing??

  5. #5

  6. #6

    Thread Starter
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

    Re: Clear Emmediate Window

    Quote Originally Posted by MartinLiss
    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.

    Thanks Martin.
    <--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
    If topic has been resolved, please pull down the Thread Tools & mark it Resolved.


    Is VB consuming your life, and is that a bad thing??

  7. #7

    Thread Starter
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

    Re: Clear Emmediate Window

    Quote Originally Posted by gavio
    Many add-ins like MZ-Tools can do it (it's even free for VB6) yey!
    If there are any members using MZTOOLS I would like to hear what they think of it.
    Thanks.
    <--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
    If topic has been resolved, please pull down the Thread Tools & mark it Resolved.


    Is VB consuming your life, and is that a bad thing??

  8. #8
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: Clear Emmediate Window

    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

  9. #9

    Thread Starter
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

    Re: Clear Emmediate Window

    Quote Originally Posted by Edgemeal
    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
    Thanks for the tip. I discovered the 255 limit last week while debugging a loop.
    <--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
    If topic has been resolved, please pull down the Thread Tools & mark it Resolved.


    Is VB consuming your life, and is that a bad thing??

  10. #10
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: Clear Emmediate Window

    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.

  11. #11

    Thread Starter
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

    Re: Clear Emmediate Window

    Quote Originally Posted by MartinLiss
    FYI I have two things that may help find links to both in my signature.
    Thanks Martin, I'll check it out.
    <--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
    If topic has been resolved, please pull down the Thread Tools & mark it Resolved.


    Is VB consuming your life, and is that a bad thing??

  12. #12
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: Clear Emmediate Window

    Quote Originally Posted by CDRIVE
    If there are any members using MZTOOLS I would like to hear what they think of it.
    Thanks.
    My 1st post already said everything - i can't do anything in VB wihtouth MZ-Tools

  13. #13

    Thread Starter
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

    Re: Clear Emmediate Window

    Quote Originally Posted by gavio
    My 1st post already said everything - i can't do anything in VB wihtouth MZ-Tools
    OK, that's clear enough.
    Thanks
    <--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
    If topic has been resolved, please pull down the Thread Tools & mark it Resolved.


    Is VB consuming your life, and is that a bad thing??

  14. #14

    Thread Starter
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

    Re: Clear Emmediate Window

    Quote Originally Posted by Edgemeal
    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
    BTW, I tried this concept by using Debug.Print VbBack hoping that it would back space over whatever was there but no go.
    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
    <--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
    If topic has been resolved, please pull down the Thread Tools & mark it Resolved.


    Is VB consuming your life, and is that a bad thing??

  15. #15
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: Clear Emmediate Window

    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
    Last edited by jcis; Jul 26th, 2008 at 10:28 PM.

  16. #16

    Thread Starter
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

    Re: Clear Emmediate Window

    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
    <--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
    If topic has been resolved, please pull down the Thread Tools & mark it Resolved.


    Is VB consuming your life, and is that a bad thing??

  17. #17
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Clear Emmediate Window

    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
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  18. #18
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: Clear Emmediate Window

    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
    Last edited by Edgemeal; Jul 27th, 2008 at 12:54 AM. Reason: Changed to Public Sub/ Module.Bas

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width