PDA

Click to See Complete Forum and Search --> : VB6 Code Formatter for VBForums


akhileshbc
Mar 19th, 2010, 11:30 PM
Hi all.... :wave:

If you have tried using the VBcode tags for posting codes in this forum, you can see that the end user can't copy it correctly as it can have line numbers and extra spaces when copied.
So, I thought about creating a custom formatter and asked about it in here: http://www.vbforums.com/showthread.php?t=607914
Based on the help from that thread (by those amazing guys), I managed to edit and regroup a project of Mark (http://www.a1vbcode.com/vbforums/Topic10851-12-1.aspx).
Keyword list were copied from koolsid's VB6CodeGenerator Addin

All credits goes to the respective owners... Thanks to them.... :wave:

Here's a demonstration of VBcode tags of the forum as well as the Formatted code...:

[[ Actual Code ]] (using VBCode tags of this forum)
Option Explicit

'~~~~ VB6 code
Private Sub Command1_Click()
Dim strTemp As String
Dim i As Long

For i = 1 To 10
Debug.Print "Hai Guys...." '~~~> Print the message
Next i
End Sub

[[ Formatted Code ]] (copy-pasted from code generated by my program)
Option Explicit

'~~~~ VB6 code
Private Sub Command1_Click()
Dim strTemp As String
Dim i As Long

For i = 1 To 10
Debug.Print "Hai Guys...." '~~~> Print the message
Next i
End Sub

I hope you all will like this code... Feel free to post your comments and suggestions... :wave:

Nightwalker83
Mar 21st, 2010, 05:00 AM
Cool! That could be a really useful program for members posting code on the forums.

Merri
Mar 21st, 2010, 05:54 AM
What I'm afraid of is that all those tags are included when counting the length of the message by the forum software, limiting the length of code postings a lot.

akhileshbc
Mar 21st, 2010, 06:40 AM
Cool! That could be a really useful program for members posting code on the forums.
Yeah... :)

What I'm afraid of is that all those tags are included when counting the length of the message by the forum software, limiting the length of code postings a lot.
Yeah... :( Do you have any solution for that...????

Another thing is, for Internet Explorer users, there is no need of using this program. Because when the VBCodes are copied (in IE browser), it will automatically gets formatted and make sure that only codes are copied excluding the line numbers.(this information was provided(to me) by 'Ellis Dee'. Thanks to him.)
I had tested it with IE8. And it's working.... :wave:
So, only FireFox users are experiencing the problem of line numbers, when VBCodes are copied...!

Merri
Mar 21st, 2010, 09:20 AM
Well, using the way you do it, the only thing I can think of is to reduce the amount of color tags. For example, most of the words are blue, so what you could do is to define blue as the base color and then color only the other parts of the code. Also, color continuous segments of the same color only once!

Your current sample code:
16 blue tags
2 green tags
= 18 total


Using my suggestion:
One blue tag around everything
5 black tags
2 green tags
= 8 total


Of course coding this optimization requires some thinking over, but that ought to be a nice learning experience :)


You can also shorten the color tags: "#000099" can be represented as #009, reducing 5 characters. Each of your current tags takes 25 characters. If all optimizations are accounted for, then 18 * 25 = 450 characters is reduced to 8 * 20 = 160 characters. That is quite a remarkable difference for the exact same final visual representation :) The length of the actual code is only 194 characters so that would still almost double the length of the code...