Color HTML tags

Hello,
I am making a program and I need to know how to color HTML tags in a RichTextBox really quickly.

My current code works like this:
(Do)
1. Use the instr to find "<"
2. Use the instr to find ">"
3. RichTextBox1.Selstart=starttag(the value of the highest)
   RichTextBox1.selstart=endtag(the value of the lower one)
4. RichTextBox1.selcolor=vbblue
(Loop until can't find)

I need a code that will increase the speed by alot.
Thanx!!
AndrewNgAsked:
Who is Participating?
 
a111a111a111Connect With a Mentor Commented:
Hi, Here is a code with the answer:

Object = "{3B7C8863-D78F-101B-B9B5-04021C009402}#1.1#0"; "RICHTX32.OCX"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form Form1


Option Explicit ' must have it

Private Sub Command1_Click()
Dim a$
Dim Start As Long
Dim st As Long
Dim ere As Long
Dim f$
Dim StartTime
Dim EndTime
Dim Rc As RichTextBox

Set Rc = Rtb    ' Create valid object reference.
Rc = Rtb
f = FreeFile
CommonDialog1.ShowOpen
Open CommonDialog1.filename For Input As f
Rc.Text = Input(LOF(f), f)
Close f

a = Rc.Text
Start = 1
Rc.SelStart = 0
Rc.SelLength = Len(Rtb)
Rc.SelColor = RGB(0, 0, 0)
Rc.SelLength = 0
Rc.Visible = False ' hide richtextbox
Screen.MousePointer = vbHourglass

StartTime = Timer
Do
  ere = InStr(Start, a, "<")
  If ere Then
    Start = ere
  Else
        Exit Do
  End If
   
  ere = InStr(Start, a, ">")
  If ere Then
    st = ere
    Rc.SelStart = Start - 1
    Rc.SelLength = st - Start + 1
    Rc.SelColor = QBColor(9)
  Else
    Exit Do
  End If
 
  Start = Start + 1
Loop

Close #1
Screen.MousePointer = vbArrow
Rc.Visible = True
EndTime = Timer
MsgBox "Done  " & EndTime - StartTime

End Sub


shay@hili.com
http://www.hili.com/~shay

0
 
a111a111a111Commented:
Hi,
1. What is the problem with the speed?
2. Are you using an old pc with low MEM?
3. Is the HTML file is so big?
4. Can you try C or C++ it is faster.
5. Try to do this in VB 5.0:
  A. Go to Project
  B. Go to Project Properties
  C. Click on the Compile TAB and make it Compile to P-Code.

No 5 here will boost your compile time and app run time.

There is a backdraw but not in your case as is.

http://www.hili.com/~shay
shay@hili.com

0
 
AndrewNgAuthor Commented:
It's not fast enough!!! I'm using a K-6 233.  I'm trying to color a really large file.  I am using p-code.
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
a111a111a111Commented:
OKAY, what is the size of the file 100 KB, 500 KB, 1MB?
0
 
a111a111a111Commented:
Also I don't know why do you need this function but I have a program Ultra Edit 5.0 that
doing the same thing in a flash 1 sec or less.
the Ultra Edit 5.0 is a Hex/Text editor.

You should download/have it .
You will not be sorry if you try the Ultra Edit 5.0


0
 
a111a111a111Commented:
You can see the example of ultra edit 5.20 at http://www.hili.com/~shay/ultraedit.jpg

I am just trying to help you and may be I missed the point and may be not!

Shay
0
 
MAVERICKCommented:
I was checking through the question... as  I worked on a similar thing for my web editor program....... Where do u  get this "ultra Edit"

0
 
AndrewNgAuthor Commented:
The file size is 549,663 bytes.  Is the source code availble of this Ultra Edit?
0
 
a111a111a111Commented:
Hi, Well not source code, its a commercial program and if you email me your email address I can send it to you.
shay@hili.com.
0
 
AndrewNgAuthor Commented:
No, I want the source code.  I already have seen programs that can do this kind of stuff really quickly.
0
 
a111a111a111Commented:
OKAY, How long it takes to process the file " 549,663 bytes."

I am about to work on it or you can ZIP your source code and the HTML file and I'll
work on it to boost the speed.

shay@hili.com
0
 
AndrewNgAuthor Commented:
Ok, I'm gonna mail it to ya in a second.  Thanx!!!
0
 
AndrewNgAuthor Commented:
Do you have ICQ?
0
 
a111a111a111Commented:
Yes 8941278.
0
 
MAVERICKCommented:
a111a111a111, can u check Q10073482
0
 
AndrewNgAuthor Commented:
Adjusted points to 185
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.