Results 1 to 9 of 9
  1. #1
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Procedure Separator Line (Word VBE 97/2000/2003)

    (I'm not sure of the terminology but will accept candidate substitutes for "procedure separator line")
    The name of the procedure reported by .CodeModule.ProcOfLine seems aberrant, as does the display (attached) in the VBE.
    Commented lines preceding the first procedure in a module are assigned the name of that procedure. (I find this awkward, to say the least, but it's what I get when I purchase a MSoft product)
    However, when some of the commented lines are continuation lines - that is, continuation lines that have been commented, VBA runs Amok (a nice Malay word!).

    When I delete the continuation characters on the lines "Debug.Print" and "GetDriveTypeStringFSO" the procedure separator line jumps up to the line "ByVal lDriveType".
    Removing that line's continuation character brings things back the way they ought to be.

    I examined this in Word97, 2000 and 2003 so I assume it is perpetrated, if that is not too soft a word, in 2002.

  2. #2
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Procedure Separator Line (Word VBE 97/2000/2003)

    I am at a bit of a loss to relate your attachment to your post! Can you elaborate?
    Regards,
    Rory

    Microsoft MVP - Excel

  3. #3
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Procedure Separator Line (Word VBE 97/2000/200

    >Can you elaborate?
    Yes, and thanks for the response.
    I Zipped the BAS and JPG because I was unsure how to attach the screen snapshot to show in the message and felt the BAS was too large for inline display.

    The JPG is a screen snapshot of my work in the Word2000 VBE. A horizontal oval highlights what I've called the "Procedure Line Separator". This line typically appears on the screen to demarcate procedures. In the case of blank and comment lines that precede the first procedure, the demarcation line appears immediately before the first such blank or comment line. In my example the demarcation line, oddly, appears immediately before the line "Next drv"; I believe this abberation is caused by the continuation characters circled nearby. Once those continuation characters are removed, the demarcation line jumps higher to the region of the (circled) "Won't work".

    The BAS is the original module which was under my programmed analysis. I was puzzled that I picked up "Next drv" as the first line of the first procedure "GetUNCPath", contrary to my expectations raised by the Help files.

    I believe that if you choose File, Import file in VBE (97, 2000, 2003) you will observe the demarcation line appearing immediately before the "Next drv" just as shown in my screen snapshot.

    The BAS and JPG in my original attached ZIP are inconsistent because I snipped out some of the source code in an endeavour to reduce the screen snapshot size for display purposes in my original post.

  4. #4
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Procedure Separator Line (Word VBE 97/2000/200

    Thanks for the clarification. (FYI, I had actually opened another zip file by mistake which, coincidentally, was also from you but contained just one userform, hence my confusion!)
    You are correct that this behaviour continues in Word 2002 as well. It must be related to the fact that the line continuation character is not commented out - you can break a comment up without prefixing the next line with an apostrophe - but why it should behave the way it does, I do not know. What issue is this causing you specifically? (or was it merely a point of note?)
    Regards,
    Rory

    Microsoft MVP - Excel

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Procedure Separator Line (Word VBE 97/2000/200

    There is clearly a bug in the way the Visual Basic Editor treats line continuation characters and comments. In your example, it's harmless - the procedure separator is displayed in an unexpected place.
    But it becomes a problem (or interesting, if you like) if you happen to place a comment ending in space+underscore immediately above a non-blank uncommented line: the uncommented line is included in the comment, making the code invalid. For example, try this:
    <code>
    ' This comment ends in a space and an underscore _
    Sub MyProc()
    Beep
    End Sub
    </code>
    See screenshot.

  6. #6
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Procedure Separator Line (Word VBE 97/2000/200

    >opened another zip file by mistake
    Oh. I've never done that (grin!)

    >What issue is this causing you specifically? (or was it merely a point of note?)
    It is by now a point-of-note, although I'd like a better subject line to assist anyone who searches for this behaviour in the future.

    Since my background is language analysis I've bit, as we say in the tirade, the bullet, and written a cheap syntax analyser.
    I no longer rely on the (IMHO) faulty ProcOfLine business.

    I believe that Rob Bovey does a better job than Microsoft in sorting out literal strings, comments, and continuation lines. His Code Cleaner logic has never let me down.

  7. #7
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Procedure Separator Line (Word VBE 97/2000/200

    (Thanks, Hans, and please see also my reply to Rory)

    >In your example, it's harmless
    Only in the visual sense. ProcOfLine trips up badly, which causes problems for anyone trying to write VBA code to step through a module on a procedure-by-procedure basis.

    >For example, try this:
    Id' rather not, it being Tuesday and the first day of the week here.(grin)
    Your sweet and clever example is either nasty or weird, I'm not sure which.
    Vote Rob Bovey for President, or at least, Programmer.

  8. #8
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Procedure Separator Line (Word VBE 97/2000/200

    It's not a bug, that's just the way it is, in both VBA and VB 6, it's a "feature".

    It's been "fixed" in VB .NET.

  9. #9
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Procedure Separator Line (Word VBE 97/2000/200

    > It's been "fixed" in VB .NET.
    Oh.
    So it's time to upgrade.
    Again (grin!)

Posting Permissions

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