Immediate Window Text Retrieval: - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Immediate Window Text Retrieval:

Pete_201Pete_201 Posts: 29Member
I use 'Debug.Print "Text"' throughout many of my procedures so that I can see which procedures were activated, in which order, using which variables, and so on.

The procedures often call other procedures depending on user inputs and complete different loops. All the procedures have been set up to end in one Procedure which is used to 'Tidy up' and tasks done by the previous procedures.

I would like this final procedure to retreive the text from the immediate window (and copy it into an array for example for reviewing at any time).

Is this possible (without finding all of my 'Debug.Print' lines, and adding something like:
[code]
ListBox1.AddItem "text"
[/code]
or
[code]
ImmediateWindowStringArray(BlankPosition) = "Text" 'declared globally
BlankPosition = BlankPosition + 1
[/code]

TIA,


Tommy Long
Business Services Team
Barclays House, Dorset

Comments

  • lionblionb Posts: 1,688Member ✭✭
    : I would like this final procedure to retreive the text from the immediate window (and copy it into an array for example for reviewing at any time).

    May be it possible but I never heard about that . Why don't you collect all your data to the Array(s) from procedure to procedure, like you do with Debug.Print, and in the final procedure collect all data together, instead of trying to retrieve data from Immediately Window?

  • infidelinfidel Posts: 2,900Member
    : : I would like this final procedure to retreive the text from the immediate window (and copy it into an array for example for reviewing at any time).
    :
    : May be it possible but I never heard about that . Why don't you collect all your data to the Array(s) from procedure to procedure, like you do with Debug.Print, and in the final procedure collect all data together, instead of trying to retrieve data from Immediately Window?

    The immediate window is part of the IDE and is only available in debug mode. It is possible to access it by writing an Add-in that uses the IDE's object model to manipulate the VB environment.

    [code]
    Private Sub LogMessageToFile(ByVal strMessage As String)
    On Error GoTo ProcedureError
    Const kstrProcedureName As String = "LogMessageToFile"

    Dim objFileSystem As New FileSystemObject
    Dim objFile As File
    Dim objStream As TextStream

    Set objFile = objFileSystem.GetFile(objFileSystem.BuildPath(App.Path, App.EXEName & ".log"))
    Set objStream = objFile.OpenAsTextStream(ForAppending)
    objStream.Write (strMessage)

    ProcedureExit:
    On Error Resume Next
    Set objFileSystem = Nothing
    Set objFile = Nothing
    Set objStream = Nothing
    Exit Sub

    ProcedureError:
    Resume ProcedureExit

    End Sub
    [/code]
Sign In or Register to comment.