Solved

Color HTML tags

Posted on 1998-08-17
16
157 Views
Last Modified: 2010-04-30
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!!
0
Comment
Question by:AndrewNg
  • 8
  • 6
  • 2
16 Comments
 
LVL 3

Expert Comment

by:a111a111a111
ID: 1429391
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
 

Author Comment

by:AndrewNg
ID: 1429392
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
 
LVL 3

Expert Comment

by:a111a111a111
ID: 1429393
OKAY, what is the size of the file 100 KB, 500 KB, 1MB?
0
 
LVL 3

Expert Comment

by:a111a111a111
ID: 1429394
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
 
LVL 3

Expert Comment

by:a111a111a111
ID: 1429395
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
 
LVL 1

Expert Comment

by:MAVERICK
ID: 1429396
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
 

Author Comment

by:AndrewNg
ID: 1429397
The file size is 549,663 bytes.  Is the source code availble of this Ultra Edit?
0
 
LVL 3

Expert Comment

by:a111a111a111
ID: 1429398
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:AndrewNg
ID: 1429399
No, I want the source code.  I already have seen programs that can do this kind of stuff really quickly.
0
 
LVL 3

Expert Comment

by:a111a111a111
ID: 1429400
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
 

Author Comment

by:AndrewNg
ID: 1429401
Ok, I'm gonna mail it to ya in a second.  Thanx!!!
0
 

Author Comment

by:AndrewNg
ID: 1429402
Do you have ICQ?
0
 
LVL 3

Expert Comment

by:a111a111a111
ID: 1429403
Yes 8941278.
0
 
LVL 1

Expert Comment

by:MAVERICK
ID: 1429404
a111a111a111, can u check Q10073482
0
 
LVL 3

Accepted Solution

by:
a111a111a111 earned 180 total points
ID: 1429405
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
 

Author Comment

by:AndrewNg
ID: 1429406
Adjusted points to 185
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now