none
Is there a way to code so at run time when a procedure runs it changes the font used in the Immediate Window to Courier (Western) before data is printed to the window output line and then changes font back b4 procedure exits? RRS feed

  • Question

  • This came up when I finally found the code for the sub below.  And added it to my code library. It is handy if you want to see how many records, fields, names of the fields, and the values in each field of a RecordSet. 

    Especially when you do NOT know in advance How many records or how many fields in each record and what is in each field of each record.

    The sample code is the name is below.

    Public Sub EnumFields(rst As Recordset, intFldLen As Integer)

    Only very annoying problem is, if you do NOT us a mono-space font like Courier (Western) in the Immediate Window AND where one or more fields have for example have a string value holding of different lengths. ( like one field holding 4 chars and next string field in same record uses 10)  and next record same fields same order might hold 2 characters in same two fields.

    Makes it very hard to line up values of each column under its column heading. Even just close to same spot. yes some values in a field has lots of "W"s other records have no "W" but lots of "I" and "1"

    Leaving the font for the Editor as Courier does make it harder to see and read for me. or I would have left editor font as Courier 


    Mark J

    Wednesday, July 31, 2019 10:45 AM

Answers

  • I have permanently set the VBE font to Consolas; it is mono-spaced and I find it easy to read.

    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Marked as answer by PuzzledByWord Thursday, September 5, 2019 6:46 PM
    Friday, August 2, 2019 7:09 AM

All replies

    1. I don't think you can change the Immediate window's font programmatically.
    2. If you were able to do so, and if you changed the font back before the procedure ends, the entire window would change back, so the effect would be nil. The Immediate window is not a Word document, where different parts of the text can have different formatting.

    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Wednesday, July 31, 2019 12:14 PM
  • Hans,

    I guess I was not clear about what I was trying to do, again, sorry.

    Part of one procedure, uses Debug.Print   To print a several column header.  

    Then uses Debug.Print to print several rows of data underneath the header holding the names of the columns.

    What I am so far unable to do is to get the data line up under the field names in the header.

    UNLESS I use a mono-space type font.  Like Courier.  ( due to "W" taking up more space than "I" for example )

    the data does not line up under the column names.

    As long as what is printed in the Immediate Window stays as a Courier font output I do not care if the font used changes back or not.

    Seems only other choices I have to use is somehow figure out how much horiz space all characters including symbols and spaces used in the record take to print.  (have not found a way for any font NOT having the same width for every character).

    Yes, I have tried Space(aNumber) , using a mono space font works great.  

    I have tried using vbTab or ',' to space out the debug.print line instead of ';'  each seems to add a fixed amount of space.

    so IF the combo of number of columns and width of data in each Field is small enough, works very well.

    Else even making the Immediate window the biggest I can still CAN prevent me from seeing the all the fields and their data.

    The code loops through records, then loops thru all the Fields in that record.  Using

    For lngFldCount = 0 To lngFields - 1

    strTemp = _

                 rst.Fields(lngFldCount)

    Debug.Print Left(strTemp _

     & Space(intFldLen), intFldLen);

    Next lndFldCount

    rst.MoveNext

    Next lngRecCount

    SO YOU CAN SEE HOW hard it can be to make sure data in columns line up, at least as far as I can figure how to adjust space columns take.

    the code was a bit long, so I just put part that prints out the values in the Fields in a horiz line.

    I hope I was clearer this time.

    Mark J


    Mark J

    Friday, August 2, 2019 3:49 AM
  • I have permanently set the VBE font to Consolas; it is mono-spaced and I find it easy to read.

    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Marked as answer by PuzzledByWord Thursday, September 5, 2019 6:46 PM
    Friday, August 2, 2019 7:09 AM