dcsimg
Results 1 to 16 of 16

Thread: Automatic "pretty listing" (reformatting) of code in VB6

  1. #1

    Thread Starter
    Fanatic Member TTn's Avatar
    Join Date
    Jul 2004
    Posts
    576

    Automatic "pretty listing" (reformatting) of code in VB6

    1. In vb.net there is a really nice time saving feature that automatically formats your code with the proper indentation.
    Type: If True then {Enter} produces
    If True Then
    { |Caret here}
    End If

    2. There is also a feature to automatically insert the end constructs for you, ie do...loop, if...Then etc.
    Type: Do {Enter} produces
    Do
    {Caret here}
    Loop

    3. Another convenient feature recently added to VB65's source code is automatic instantiation of dimensioned variables (common data types only).
    Type: Dim i as long {Enter} produces
    Dim i As Long: i=0

    Type: Dim x,y,z as double {Enter} produces
    Dim x, y, z As Double: x=0: y=0: z=0

    Type Dim o as object {Enter} produces
    Dim o As Object: Set o = Nothing

    EDIT: Video link

    Has anyone else achieved these features in production? For example, an Add-in.
    Thanks
    Last edited by TTn; May 22nd, 2019 at 02:24 AM. Reason: added video

  2. #2
    Hyperactive Member
    Join Date
    Jan 2015
    Posts
    304

    Re: Automatic "pretty listing" (reformatting) of code in VB6

    VBIDEUtils does it very well, and many more things.
    I use it everyday (of course, I wrote it also)

    Search on the forum, you'll have the link for the sources, as it is now open source

  3. #3

    Thread Starter
    Fanatic Member TTn's Avatar
    Join Date
    Jul 2004
    Posts
    576

    Re: Automatic "pretty listing" (reformatting) of code in VB6

    Quote Originally Posted by Thierry69 View Post
    VBIDEUtils does it very well, and many more things.
    I use it everyday (of course, I wrote it also)

    Search on the forum, you'll have the link for the sources, as it is now open source
    Does VBIDEUtils perform the code formatting automatically? I am looking at your indent source code, and don't see direct access to the codemodule.

  4. #4
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    12,928

    Re: Automatic "pretty listing" (reformatting) of code in VB6

    I did have a formatting addin installed on an older PC but can't remember what it was called. Rather than being automatic it added a little button in the IDE that when clicked reformatted the code in the active window. It was rather useful though not as nice as the one in the VB.Net IDE

  5. #5
    Hyperactive Member
    Join Date
    Jan 2015
    Posts
    304

    Re: Automatic "pretty listing" (reformatting) of code in VB6

    Not, it is not automatic, but a click on the button in the toolbar can indent procedure or module.
    And in the menu, the whole project.

    Beside, yoou have alot of very usefull options.

  6. #6

    Thread Starter
    Fanatic Member TTn's Avatar
    Join Date
    Jul 2004
    Posts
    576

    Re: Automatic "pretty listing" (reformatting) of code in VB6

    Thanks guys, I've seen a few add-ins with the button reformat feature and an options panel for related settings.
    Automatic reformatting is a significant improvement in practice.

    Thierry69, you were several years ahead in 99. Good work pioneering this field! Although, direct access to the IDE/VBE makes the process easier, cleaner, and fully compatible (with add-ins).

  7. #7
    Hyperactive Member
    Join Date
    Jan 2015
    Posts
    304

    Re: Automatic "pretty listing" (reformatting) of code in VB6

    TTn, yes
    I was belong the first to develop addin for VB6 (and other stuff too)

  8. #8
    Frenzied Member wqweto's Avatar
    Join Date
    May 2011
    Posts
    1,554

    Re: Automatic "pretty listing" (reformatting) of code in VB6

    http://rubberduckvba.com/

    I think it has both on demand re-formatting of modules/project and automatic caret placement and insertion of closing bracket/quotes like most modern code-editors (e.g. N++ and VS) but personally don't use it so might be wrong.

    cheers,
    </wqw>

  9. #9
    Hyperactive Member
    Join Date
    Jan 2015
    Posts
    304

    Re: Automatic "pretty listing" (reformatting) of code in VB6

    Rubberduck is not so bad also, but totally slow and not working on big projects.
    On my projects (quite big), it crashes and takes toomuch time to load

  10. #10

    Thread Starter
    Fanatic Member TTn's Avatar
    Join Date
    Jul 2004
    Posts
    576

    Re: Automatic "pretty listing" (reformatting) of code in VB6

    Yes, it looks like rubberduck has some similar features, but that last version I tried was not really stable.
    At least 2 forum members including myself had to reinstall VB6 just to clear the corruption. Luckily, it was on my test machine.
    Rubberduck crashed several times on me, and the splash screen took way to long to load. Way to long!
    To give some credit to their team, it seems like a decent project in the early alpha stage.

  11. #11
    Frenzied Member
    Join Date
    Sep 2012
    Posts
    1,608

    Re: Automatic "pretty listing" (reformatting) of code in VB6

    In my code editor, I plan to provide a "smart code completion" feature like VB.NET. But at the moment, I'm still not making progress on "code parsing". I need to implement a "generic code parser" like VSCode, but I haven't found the best solution yet.

    In addition, VB.NET-like "code smart completion" functionality can be implemented by developing plug-ins for VSCode, but no one seems to do this because few people use VSCode to write VB6 or VB.NET code.

  12. #12
    PowerPoster
    Join Date
    Feb 2006
    Posts
    20,543

    Re: Automatic "pretty listing" (reformatting) of code in VB6

    There are lots of IDE add-ins. Use the one you like or write your own.

    I rarely leave any loaded anymore besides the Resource Editor though. Too many IDE crashes, too much lost work. No thanks.

  13. #13

    Thread Starter
    Fanatic Member TTn's Avatar
    Join Date
    Jul 2004
    Posts
    576

    Re: Automatic "pretty listing" (reformatting) of code in VB6

    Quote Originally Posted by dilettante View Post
    There are lots of IDE add-ins. Use the one you like or write your own.

    I rarely leave any loaded anymore besides the Resource Editor though. Too many IDE crashes, too much lost work. No thanks.
    Same here. This is exactly why direct access to the VBE is a better way to reformat code. Addins are not usually compatible with other addins, so that old technique to extend VB6 is somewhat flawed nowadays, unless you get or make one single addin that is stable with most of the features you need.

  14. #14

    Thread Starter
    Fanatic Member TTn's Avatar
    Join Date
    Jul 2004
    Posts
    576

    Re: Automatic "pretty listing" (reformatting) of code in VB6

    It looks like Rubberduck has bounced like a check on these completion features. Has anyone seen this work on any version?
    I just downloaded version 2.4.1 and it does not automatically reformat code as advertised in their video for v2.3. The end constructs are not automatically inserted either. There aren't even any options to do so.

    I just completed a stable version of VB6.5 with a full set of reformatting features virtually identical to vb.net. You can even drop code into the VB editor to automatically reformat it with proper indentation.
    It really is convenient to have this option in a VB6 style code editor! I will upload a video later.

  15. #15
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    5,441

    Re: Automatic "pretty listing" (reformatting) of code in VB6

    Quote Originally Posted by TTn View Post
    ...
    Type: Dim x,y,z as double {Enter} produces
    Dim x, y, z As Double: x=0: y=0: z=0
    ...
    Since VB initializes the simple types to their default, i.e. 0.0 in the case of doubles, the additional code added to the line just seems redundant and superfluous.

    Also, unless the compiler is being overridden somehow, the above code should create two variants and a double. And because of the initialization, the x and y variants would contain integers because of the initialization.

    I don't know that I would want the IDE to automatically create bad code for me.

  16. #16

    Thread Starter
    Fanatic Member TTn's Avatar
    Join Date
    Jul 2004
    Posts
    576

    Re: Automatic "pretty listing" (reformatting) of code in VB6

    Quote Originally Posted by passel View Post
    Since VB initializes the simple types to their default, i.e. 0.0 in the case of doubles, the additional code added to the line just seems redundant and superfluous.
    Also, unless the compiler is being overridden somehow, the above code should create two variants and a double. And because of the initialization, the x and y variants would contain integers because of the initialization.
    Well of course the default is 0, this (particular option) gives you a placement to change it without having to type colon equals :i=7, which requires a contorted shift key to be held on various keyboards that may have different key positions.

    Yes there is a sort of override for that, but not implemented in this version. It is indeed better to dimension single variables one line at a time to avoid accidents, so that is still recommended for current use.

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width