Results 1 to 28 of 28

Thread: [RESOLVED] Parsing and coloring the VB CODES in my Richtextbox [SUGGESTIONS & HELP NEEDED]

  1. #1

    Thread Starter
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Resolved [RESOLVED] Parsing and coloring the VB CODES in my Richtextbox [SUGGESTIONS & HELP NEEDED]

    Hi all...

    I am trying to create a small vb6 code viewer.Which will simply display the VB6 codes in color coded form. See below for an example:
    vb Code:
    1. Option Explicit
    2.  
    3. Private Sub Command1_Click()  '~~~ Search button
    4.   Dim i As Long
    5.  
    6.   List2.Clear '~~~> Empty everything
    7.   For i = 0 To List1.ListCount - 1  '~~~> Loop through the list in 1st Listbox
    8.     If InStr(1, List1.List(i), Trim$(Text1.Text), vbTextCompare) <> 0 Then  '~~> Checking for the entry
    9.       List2.AddItem List1.List(i) '~~~> If found, add it to the 2nd Listbox
    10.     End If
    11.   Next i
    12. End Sub
    13.  
    14. Private Sub Form_Load()
    15.   '~~~ Load the listbox with sample data
    16.   List1.AddItem "D:\MUSIC\Music Collection Updated\Akon ft nas - locked up rmx.mp3"
    17.   List1.AddItem "D:\MUSIC\Music Collection Updated\Ciara - Oh.mp3"
    18.   List1.AddItem "C:\MUSIC\Music Collection Updated\Fabolous - Can U hear me.mp3"
    19.   List1.AddItem "C:\MUSIC\Music Collection Updated\Fabolous - Cant_let_you_go.mp3"
    20. End Sub
    Here, the reserved words are set with the blue color, comments with green, constants(numbers) with pink and text with brown.

    How can I implement the same coloring methods in my own VB6 code viewer..????

    Any ideas...???
    Thanks....

    Edit:
    I know the basic methods for finding and changing words by using Find method of RichTextBox and some basic manipulations using InStr(), Mid(), Replace(), etc...
    But I was looking for something that is more efficient and speedy, because the code might be of large lines....
    For displaying the VBCode, I will be using a RichtTextbox...
    Thanks...
    Last edited by akhileshbc; Mar 19th, 2010 at 06:49 AM. Reason: added more information

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Parsing and coloring the VB CODES in my Richtextbox [SUGGESTIONS & HELP NEEDED]


  3. #3
    PowerPoster Keithuk's Avatar
    Join Date
    Jan 2004
    Location
    Staffordshire, England
    Posts
    2,236

    Re: Parsing and coloring the VB CODES in my Richtextbox [SUGGESTIONS & HELP NEEDED]

    Quote Originally Posted by akhileshbc View Post
    I am trying to create a small vb6 code viewer.Which will simply display the VB6 codes in color coded form.
    Well what I use to display VB code on A1vbcode is Mark's Syntax.zip. It displays the code in a web browser then you just copy and paste it into you reply. Its a pity we don't use a similar code on here. The VB Code used to be good but you can only copy one line at a time. I know some uses and made a vb app to copy and paste the code but you should have to its only text. I don't know if thats what you mean?
    Keith

    I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

  4. #4

    Thread Starter
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: Parsing and coloring the VB CODES in my Richtextbox [SUGGESTIONS & HELP NEEDED]

    Quote Originally Posted by Keithuk View Post
    Well what I use to display VB code on A1vbcode is Mark's Syntax.zip. It displays the code in a web browser then you just copy and paste it into you reply. Its a pity we don't use a similar code on here. The VB Code used to be good but you can only copy one line at a time. I know some uses and made a vb app to copy and paste the code but you should have to its only text. I don't know if thats what you mean?
    Thanks Keith...

    Yeah, exactly... That's what I want to achieve....
    Thanks Hack....

    rep+ both of you...

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  5. #5
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

    Re: Parsing and coloring the VB CODES in my Richtextbox [SUGGESTIONS & HELP NEEDED]

    As my friend Keith stated, Marks 'Syntax Highlighter' does a really nice job. I would use it here on VBF if I could. There are also a few similar apps on PSC.
    <--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
    If topic has been resolved, please pull down the Thread Tools & mark it Resolved.


    Is VB consuming your life, and is that a bad thing??

  6. #6
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: [RESOLVED] Parsing and coloring the VB CODES in my Richtextbox [SUGGESTIONS & HEL

    Quote Originally Posted by akhileshbc View Post
    I am trying to create a small vb6 code viewer.Which will simply display the VB6 codes in color coded form. See below for an example:

    Akhil

    You seem to have some good replies already.

    About all I'd be good for would be to suggest a brute-force approach,
    well, at least for reserved words -- you'd need a list of them, and if found,
    set color to blue. Comments could just be handled by looking for
    apostrophe. And so on...

    Do you want to go that route, or are you satisfied with other guys' replies?

    Spoo

  7. #7

    Thread Starter
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: Parsing and coloring the VB CODES in my Richtextbox [SUGGESTIONS & HELP NEEDED]

    Quote Originally Posted by CDRIVE View Post
    As my friend Keith stated, Marks 'Syntax Highlighter' does a really nice job. I would use it here on VBF if I could. There are also a few similar apps on PSC.
    Thanks CDRIVE....

    I tried that one, but it is giving some errors on runtime..!
    Key is already assigned with an element to this collection
    I think it is due to some duplicate entries in keywords.txt file. (like cbool, cbyte, etc having two copies of each)....
    But the EXE file attached to it, is working perfect...
    I will play with codes and will post here if I am stuck at any part...

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  8. #8
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: [RESOLVED] Parsing and coloring the VB CODES in my Richtextbox [SUGGESTIONS & HEL

    Ah!!!!

    I have tried the code before... in fact I have it in my laptop... I have implemented the same in the Code Generator... See the link in my signature
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  9. #9

    Thread Starter
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: [RESOLVED] Parsing and coloring the VB CODES in my Richtextbox [SUGGESTIONS & HEL

    Quote Originally Posted by Spoo View Post
    Akhil

    You seem to have some good replies already.

    About all I'd be good for would be to suggest a brute-force approach,
    well, at least for reserved words -- you'd need a list of them, and if found,
    set color to blue. Comments could just be handled by looking for
    apostrophe. And so on...

    Do you want to go that route, or are you satisfied with other guys' replies?

    Spoo
    Thanks spoo....
    Could you show a small sample or an example for describing the 'brute-force approach' (it's a new term for me )...
    Edit: I found it after Googling. Thanks...
    Last edited by akhileshbc; Mar 19th, 2010 at 08:02 AM. Reason: found the details about brute-forcing

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  10. #10

    Thread Starter
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: [RESOLVED] Parsing and coloring the VB CODES in my Richtextbox [SUGGESTIONS & HEL

    Quote Originally Posted by koolsid View Post
    Ah!!!!

    I have tried the code before... in fact I have it in my laptop... I have implemented the same in the Code Generator... See the link in my signature
    Wow that's a nice one...
    Do you have the source code...???? I mean, do you mind sharing it with us...

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  11. #11
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: [RESOLVED] Parsing and coloring the VB CODES in my Richtextbox [SUGGESTIONS & HEL

    Sure pm me your email address... In the mean time I'll search my laptop for the same... Also go through the attachment and see the help file. The .Hlp file has pictures so you can see how the codes automatically gets formatted (colored) in the RTB
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  12. #12

    Thread Starter
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: [RESOLVED] Parsing and coloring the VB CODES in my Richtextbox [SUGGESTIONS & HEL

    Quote Originally Posted by koolsid View Post
    Sure pm me your email address... In the mean time I'll search my laptop for the same... Also go through the attachment and see the help file. The .Hlp file has pictures so you can see how the codes automatically gets formatted (colored) in the RTB
    Done....

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  13. #13
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: [RESOLVED] Parsing and coloring the VB CODES in my Richtextbox [SUGGESTIONS & HEL

    Sent
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  14. #14
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: [RESOLVED] Parsing and coloring the VB CODES in my Richtextbox [SUGGESTIONS & HEL

    Akhil

    "Brute-force" -- as in not terribly elegant or efficient, but gets the job done

    Anyway, before posting code, let me see if I understand your situation.
    I'm assuming that you would..

    1. Open a .FRM file as a text file
    2. Skip over the control definitions and get to declarations and then subs and functions
    3. Load your RTB with 20 or so lines of code
    4. Have a text file that contains reserved words, say RW.txt
    5. Look up each word in the RTB in RW.txt -- if found, set color to blue
    6. If find apostrophe, set rest of line to green (comment).
    7. and so on...

    Is that what you are thinking of doing?

    EDIT: I'm too late, I guess .. looks like you and Kool are on to something better.

    Spoo

  15. #15
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: [RESOLVED] Parsing and coloring the VB CODES in my Richtextbox [SUGGESTIONS & HEL

    Spoo you are on the right track but instead of using the Text File I have declared the words in a string for example

    Code:
        VB6ReservedWords = "Or|Do|And|Random|Append|Binary|Exit|Then|GoTo|Case|Select|End|ReDim|" _
        & "For|Each|Loop|While|Until|Next|True|False|Sub|Function|As|Private|Dim|Open|Access|" _
        & "Else|ElseIf|Public|Close|Open|If|ByVal|(ByVal|Set|Nothing|Option|Explicit|Declare|" _
        & "Long|Long,|Long)|Lib|LBound|UBound|With|Call|Integer|Integer,|Integer)|Read|Lock|" _
        & "Byte|Byte)|Byte,|Double|Double)|Double,|Boolean|Boolean)|Boolean,|Any|Any,|Any)|" _
        & "Currency|Currency,|Currency)|Date|Date,|Date)|New|New,|New)|Object|Object,|Object)|" _
        & "Single|Single,|Single)|String|String,|String)|Variant|Variant,|Variant)|Alias|Const|" _
        & "Public|Not|Enum|Static|Friend|ByRef|(ByRef|ParamArray|Type|WithEvents|Resume|Is|Set|" _
        & "Debug.Assert|Debug.Print|False:|Else:|Global|EndIf"
            
        MyArray = Split(VB6ReservedWords, "|")
    I am also using the LockWindowUpdate API to ensure that the RTB doesn't flicker when the words get colored... If you see the help file in the attachment in that link, you will see the snapshots on how it looks...
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  16. #16

    Thread Starter
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: [RESOLVED] Parsing and coloring the VB CODES in my Richtextbox [SUGGESTIONS & HEL

    Quote Originally Posted by Spoo View Post
    Akhil

    "Brute-force" -- as in not terribly elegant or efficient, but gets the job done

    Anyway, before posting code, let me see if I understand your situation.
    I'm assuming that you would..

    1. Open a .FRM file as a text file
    2. Skip over the control definitions and get to declarations and then subs and functions
    3. Load your RTB with 20 or so lines of code
    4. Have a text file that contains reserved words, say RW.txt
    5. Look up each word in the RTB in RW.txt -- if found, set color to blue
    6. If find apostrophe, set rest of line to green (comment).
    7. and so on...

    Is that what you are thinking of doing?

    EDIT: I'm too late, I guess .. looks like you and Kool are on to something better.

    Spoo
    Yeah... But some changes... I thought about creating a program that can open the project files(frm and mod) and parse the code blocks (or the pasted codeblocks - in a Richtextbox) to be formatted for displaying it in this forum. The vbCode tags in this forum has a disadvantage that, it will display line numbers on the codes, which makes it difficult for the end user to copy the CODE. So, if the code is formatted in such a way that, it will color it just like the vbCodes but wrapped inside the CODE tags, it will certainly be a help for both the users. I was trying to create such a program....

    Thanks...

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  17. #17
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: [RESOLVED] Parsing and coloring the VB CODES in my Richtextbox [SUGGESTIONS & HEL

    Kool

    Cool list of reserved words

    Akhil

    Nice project. And I get your point about line numbers when using VBCode wrapper.
    I see you've marked this as RESOLVED, so I'll stand down.

    Spoo

  18. #18

    Thread Starter
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: [RESOLVED] Parsing and coloring the VB CODES in my Richtextbox [SUGGESTIONS & HEL

    Quote Originally Posted by Spoo View Post
    Akhil

    Nice project. And I get your point about line numbers when using VBCode wrapper.
    I see you've marked this as RESOLVED, so I'll stand down.

    Spoo
    Thanks to you and all those who had helped me... Thanks guys....

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  19. #19
    PowerPoster Keithuk's Avatar
    Join Date
    Jan 2004
    Location
    Staffordshire, England
    Posts
    2,236

    Re: [RESOLVED] Parsing and coloring the VB CODES in my Richtextbox [SUGGESTIONS & HEL

    So if this topic is Resolved which method have you used?
    Keith

    I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

  20. #20

    Thread Starter
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: [RESOLVED] Parsing and coloring the VB CODES in my Richtextbox [SUGGESTIONS & HEL

    Quote Originally Posted by Keithuk View Post
    So if this topic is Resolved which method have you used?
    I am trying out the 3 methods... Hack's one, Keith's and Koolsid's (from his addin). I am playing with these three methods and trying to understand the techniques used

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  21. #21
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: [RESOLVED] Parsing and coloring the VB CODES in my Richtextbox [SUGGESTIONS & HEL

    Quote Originally Posted by koolsid View Post
    Spoo you are on the right track but instead of using the Text File I have declared the words in a string for example

    Code:
        VB6ReservedWords = "Or|Do|And|Random|Append|Binary|Exit|Then|GoTo|Case|Select|End|ReDim|" _
        & "For|Each|Loop|While|Until|Next|True|False|Sub|Function|As|Private|Dim|Open|Access|" _
        & "Else|ElseIf|Public|Close|Open|If|ByVal|(ByVal|Set|Nothing|Option|Explicit|Declare|" _
        & "Long|Long,|Long)|Lib|LBound|UBound|With|Call|Integer|Integer,|Integer)|Read|Lock|" _
        & "Byte|Byte)|Byte,|Double|Double)|Double,|Boolean|Boolean)|Boolean,|Any|Any,|Any)|" _
        & "Currency|Currency,|Currency)|Date|Date,|Date)|New|New,|New)|Object|Object,|Object)|" _
        & "Single|Single,|Single)|String|String,|String)|Variant|Variant,|Variant)|Alias|Const|" _
        & "Public|Not|Enum|Static|Friend|ByRef|(ByRef|ParamArray|Type|WithEvents|Resume|Is|Set|" _
        & "Debug.Assert|Debug.Print|False:|Else:|Global|EndIf"
            
        MyArray = Split(VB6ReservedWords, "|")
    I am also using the LockWindowUpdate API to ensure that the RTB doesn't flicker when the words get colored... If you see the help file in the attachment in that link, you will see the snapshots on how it looks...
    I put all of my keywords in an access database. That makes it easy to add/remove/whatever.

  22. #22
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: [RESOLVED] Parsing and coloring the VB CODES in my Richtextbox [SUGGESTIONS & HEL

    Many ways to skin a cat (Forgive me P.E.T.A), Hack
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  23. #23
    PowerPoster Ellis Dee's Avatar
    Join Date
    Mar 2007
    Location
    New England
    Posts
    3,530

    Re: [RESOLVED] Parsing and coloring the VB CODES in my Richtextbox [SUGGESTIONS & HEL

    Quote Originally Posted by Keithuk View Post
    Its a pity we don't use a similar code on here. The VB Code used to be good but you can only copy one line at a time. I know some uses and made a vb app to copy and paste the code but you should have to its only text.
    Quote Originally Posted by akhileshbc View Post
    The vbCode tags in this forum has a disadvantage that, it will display line numbers on the codes, which makes it difficult for the end user to copy the CODE.
    You guys should know that the VB Code tags here on vbforums were fixed last year. Copying code that has line numbers is no longer a problem; just copy & paste as normal and it works without a hitch. Code copies properly, line numbers are ignored, and no 3rd party helper application is required.

  24. #24

    Thread Starter
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: [RESOLVED] Parsing and coloring the VB CODES in my Richtextbox [SUGGESTIONS & HEL

    Quote Originally Posted by Ellis Dee View Post
    You guys should know that the VB Code tags here on vbforums were fixed last year. Copying code that has line numbers is no longer a problem; just copy & paste as normal and it works without a hitch. Code copies properly, line numbers are ignored, and no 3rd party helper application is required.
    Thanks Ellis....

    But I think it is not yet fixed....! I just tried the code in the first post and it's the same as in the previous days (includes the numbers)

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  25. #25

    Thread Starter
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: [RESOLVED] Parsing and coloring the VB CODES in my Richtextbox [SUGGESTIONS & HEL

    I had posted the project in our CodeBank... : http://www.vbforums.com/showthread.php?t=608000 ...

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  26. #26
    PowerPoster Ellis Dee's Avatar
    Join Date
    Mar 2007
    Location
    New England
    Posts
    3,530

    Re: [RESOLVED] Parsing and coloring the VB CODES in my Richtextbox [SUGGESTIONS & HEL

    Quote Originally Posted by akhileshbc View Post
    Thanks Ellis....

    But I think it is not yet fixed....! I just tried the code in the first post and it's the same as in the previous days (includes the numbers)
    Works fine for me, but I use Internet Explorer. It's probably your browser.

  27. #27

    Thread Starter
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: [RESOLVED] Parsing and coloring the VB CODES in my Richtextbox [SUGGESTIONS & HEL

    Quote Originally Posted by Ellis Dee View Post
    Works fine for me, but I use Internet Explorer. It's probably your browser.
    For me it's Firefox 3 ...

    Edit:
    Yeah, I tried copying codes using IE8 and it's working fine... Only Firefox is having the problem....
    Last edited by akhileshbc; Mar 20th, 2010 at 12:06 AM.

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  28. #28
    PowerPoster Ellis Dee's Avatar
    Join Date
    Mar 2007
    Location
    New England
    Posts
    3,530

    Re: [RESOLVED] Parsing and coloring the VB CODES in my Richtextbox [SUGGESTIONS & HEL

    That's the danger of using the "little guy" browser.

Posting Permissions

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



Click Here to Expand Forum to Full Width