VS 2017 Code Colorizer-VBForums
Results 1 to 14 of 14

Thread: Code Colorizer

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2017
    Posts
    1

    Code Colorizer

    I've not used VB since VB6 but am wanting to get back into it.

    I need an app that will hold code snippets, so I want to build something like this: http://www.fmsinc.com/MicrosoftAccess/modules/index.asp

    I had built one years ago in VB6, but I've long since lost that code.

    Is there something that will do the coloring/formatting of pasted code for various languages (php, vb.net, vba, etc...) like I had years ago?

    Thanks!

    Morgan

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    97,049

    Re: Code Colorizer

    I think that there's something in the VB.NET CodeBank forum that can do that in a RichTextBox. I think it's entitled "Fast Syntax Highlighting" or the like, although I'm not sure.

    Alternatively, I think that the code editor from SharpDevelop can be used on its own. SharpDevelop is open-source so, at the least, you may well be able to use the same code as long as you abide by the license conditions.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    PowerPoster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,001

    Re: Code Colorizer

    You want to look into Microsoft PowerPack...it is free.

    https://www.microsoft.com/en-us/down....aspx?id=25169

    It has various color schemes and I believe one is highlighting different languages in the same solution. I like having the lines linking indented code on:
    Attached Images Attached Images  
    In order to understand recursion, one must first understand recursion….

  4. #4
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    97,049

    Re: Code Colorizer

    Quote Originally Posted by TysonLPrice View Post
    You want to look into Microsoft PowerPack...it is free.

    https://www.microsoft.com/en-us/down....aspx?id=25169

    It has various color schemes and I believe one is highlighting different languages in the same solution. I like having the lines linking indented code on:
    I don't understand what the VB PowerPacks have to do with the question. Have you linked to the wrong thing?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5
    PowerPoster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,001

    Re: Code Colorizer

    Quote Originally Posted by jmcilhinney View Post
    I don't understand what the VB PowerPacks have to do with the question. Have you linked to the wrong thing?
    I was refering to this:

    Is there something that will do the coloring/formatting of pasted code for various languages (php, vb.net, vba, etc...) like I had years ago?
    VB PowerPacks has the colored tabs by language. It may not work for the OP as asked but I didn't see any harm in posting it.
    In order to understand recursion, one must first understand recursion….

  6. #6
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    97,049

    Re: Code Colorizer

    Quote Originally Posted by TysonLPrice View Post
    I was refering to this:



    VB PowerPacks has the colored tabs by language. It may not work for the OP as asked but I didn't see any harm in posting it.
    Either I'm missing something here or you are. VB PowerPacks is a group of Windows Forms components including shapes like LineShape, DataRepeater and PrintForm. It has nothing to do with colouring text, as far as I'm aware. I have no idea what you're referring to. If I'm wrong then I'm keen to find out what exactly you mean, but I think that you must be thinking of something other than VB PowerPacks. Did you maybe mean PowerTools?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7
    PowerPoster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,001

    Re: Code Colorizer

    Sorry guys...my bad.
    Attached Images Attached Images  
    In order to understand recursion, one must first understand recursion….

  8. #8
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    97,049

    Re: Code Colorizer

    Quote Originally Posted by TysonLPrice View Post
    Sorry guys...my bad.
    That's an add-in for VS. My impression was that the OP was looking for a control they could add to their own application that would allow them to colour syntax at run time, not something to colour syntax in VS when they're building the app. Maybe I misinterpreted it.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  9. #9
    Fanatic Member ChrisE's Avatar
    Join Date
    Jun 2017
    Location
    Frankfurt
    Posts
    718

    Re: Code Colorizer

    Hi,
    I have done this with VB6 and can post the Code for -ColorizeWords-,
    you would have to convert it to .net
    let me know if you want it.

    regards
    Chris
    to hunt a species to extinction is not logical !
    since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.

  10. #10
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    97,049

    Re: Code Colorizer

    Quote Originally Posted by ChrisE View Post
    Hi,
    I have done this with VB6 and can post the Code for -ColorizeWords-,
    you would have to convert it to .net
    let me know if you want it.

    regards
    Chris
    I'd expect that VB.NET code would significantly different enough that a conversion would be more work than it was worth.

    Here are a few options I found in the VB.NET CodeBank by searching for "syntax":

    http://www.vbforums.com/showthread.p...ghlight=syntax
    http://www.vbforums.com/showthread.p...ghlight=syntax
    http://www.vbforums.com/showthread.p...ghlight=syntax
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  11. #11
    Fanatic Member ChrisE's Avatar
    Join Date
    Jun 2017
    Location
    Frankfurt
    Posts
    718

    Re: Code Colorizer

    Quote Originally Posted by jmcilhinney View Post
    I'd expect that VB.NET code would significantly different enough that a conversion would be more work than it was worth.
    Hi Jmc,

    yes your right, just went threw the Links, everything is there
    to get started.

    regards
    Chris
    to hunt a species to extinction is not logical !
    since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.

  12. #12
    You don't want to know.
    Join Date
    Aug 2010
    Posts
    4,143

    Re: Code Colorizer

    Here's the skinny as far as I know it: you don't want to try writing it yourself.

    There are plenty of decent examples for making a RichTextBox do this. It takes some not-obvious magic to make it perform reasonably well. RichTextBox wasn't really made for that kind of on-the-fly formatting, but if you do tricks like "only format the visible areas" or "try to do some parsing work in the background" you can get pretty far.

    If you try to do it yourself the most obvious way, it's going to be too slow once you hit about 100 lines. The stuff JMC linked is going to be your best bet.

    Another option might be to see if SharpDevelop has still published their editor. It was the syntax-highlighting editor behind the SharpDevelop IDE for years, and available as Open-Source. Heck, at one point they had a free e-book published about how they implemented it, I'm ashamed I didn't have the attention span to finish it but I was like, 19 and still too green to grasp it.

    I'm pretty sure SharpDevelop moved on to a WPF-based editor, those are nice because the text rendering engine in WPF gives you a lot more power as the programmer. To some extent you can treat every letter in the control as if it were an individual Label, which is very convenient for almost everything you want to do in an IDE.

    I think there's a second WPF editor but I have a feeling it's just the new SharpDevelop one with a different "brand".
    Nothing I post is production-ready. It is provided as-is, use it at your own risk.

  13. #13
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,398

    Re: Code Colorizer

    ScintillaNET is a great free control which you can use to create your own code editor, it has most features in a powerful editor Notepad++



  14. #14
    You don't want to know.
    Join Date
    Aug 2010
    Posts
    4,143

    Re: Code Colorizer

    Oh cool, that editor's been around for a while but when I was last looking there weren't any .NET wrappers of it!
    Nothing I post is production-ready. It is provided as-is, use it at your own risk.

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

Survey posted by VBForums.