Library code snippets
Colour HTML Tags (2)
This is another example of how to colour HTML tags. Add a RichTextBox to your form, and a command button called cmdColour. Then use the following code
Private Sub ColorHTML(RTF As RichTextBox)
Dim sHTML As String
Dim nTagOpen As Long
Dim nTagClose As Long
Dim nI As Long
Dim nColor As Long
sHTML = RTF.Text
nTagClose = 1
With RTF
For nI = 1 To Len(sHTML)
' *** See where the next tag
starts.
nTagOpen = InStr(nTagClose,
sHTML, "<")
If nTagOpen = 0 Then Exit For
If LCase(Mid(sHTML, nTagOpen,
4)) = "<img" Then
nColor =
&H400040
ElseIf LCase(Mid(sHTML,
nTagOpen, 2)) = "<a" Then
nColor =
&H8080&
ElseIf LCase(Mid(sHTML,
nTagOpen, 2)) = "<b" Then
nColor =
&H8000000F
Else
nColor =
&H4000&
End If
' *** See where the tag ends.
nTagClose = InStr(nTagOpen,
sHTML, ">")
If nTagOpen = 0 Then nTagClose
= Len(sHTML)
If nTagClose = 0 Then nTagClose
= Len(sHTML)
' *** Color the tag.
.SelStart = nTagOpen - 1
.SelLength = nTagClose -
nTagOpen + 1
.SelColor = nColor
Next
End With
End Sub
Private Sub cmdColour_Click()
ColorHTML RichTextBox1
End Sub
Related articles
Related discussion
-
Run-time error '91'
by converter2009 (1 replies)
-
VB6 Runtime error 381 subsript out of range Error
by Uncle (2 replies)
-
passing and reading parameters from using Shell
by jigartoliya (0 replies)
-
Convert C++ code to VB6
by mawcot (4 replies)
-
listbox scrollbar
by Dennijr (10 replies)
Related podcasts
-
Christian Beauclair
14 mai 2008 (�mission #0074) ::.Christian Beauclair: Stratégies de migration VB6 vers .NET Nous discutons avec Christian Beauclair des stratégies de migration VB6 vers .NET. Entre autres, nous discutons comment utiliser le "VB 6 Code Advisor" et le "Interop Forms Toolkit" pour ajouter la puiss...
This thread is for discussions of Colour HTML Tags (2).