I am developing a custom web control. At this time , i am coding the tags. I am trying to make the rich text box , understand all the html tags, until now i have done the following but i have problems with some:
<html></html>,
<font></font>,
<li></li>,
<br>,
<p></p>,
<left></left>,
<center></center>,
<right></right>,
<body></body>,
i know i have more to do but i am stack at to tags.
The first (hyperlink tag) :
<a href="http://www.mysite.com/">Test</a>
I don't know how to load the url and create an url link in Rich Text Box.
The secont (image tag):
<img src="image.gif">Test Image</img>
I don't know how to load the image url fro mthis tag and load the image into a Rich Text Box.
Here is the code for FONT tag:
Rich Text Box's Name = Page
Form's Name = Form1
Function FormatFont()
'Find the font tag
Dim tFont As Integer
tFont = InStr(tFont + 1, Form1.Page.Text, "<font ", vbTextCompare)
While tFont > 0
Dim eFont As Integer
eFont = InStr(tFont + 1, Form1.Page.Text, "</font>", vbTextCompare)
If (eFont > tFont) Then
'find whats between these
Dim hFindFont As String
Dim hFontSize As Variant
Dim hFontName As String
Dim etFont As Integer
etFont = InStr(tFont + 1, Form1.Page.Text, ">", vbBinaryCompare)
If ((etFont > tFont) And (etFont < eFont)) Then
'select what we want
Form1.Page.SelStart = tFont + 5
Form1.Page.SelLength = (etFont - 2) - (tFont + 5)
hFindFont = Form1.Page.SelText
hFontName = FindFontName(hFindFont)
hFontSize = FindFontSize(hFindFont)
Form1.Page.SelStart = etFont
Form1.Page.SelLength = (eFont - 1) - (etFont)
Form1.Page.SelFontName = hFontName
Form1.Page.SelFontSize = hFontSize
End If
End If
tFont = InStr(tFont + 1, Form1.Page.Text, "<font ")
Wend
End Function
Function FindFontName(line As String)
Dim name As Integer
Dim space As Integer
name = InStr(name + 1, line, "name=", vbTextCompare)
If (name > 0) Then
space = InStr(name + 1, line, "", vbTextCompare)
If (space > name) Then
Dim L1 As Integer
L1 = Len(Mid(line, name + 6))
FindFontName = Mid(line, name + 6, L1)
Else
FindFontName = Mid(line, name + 6, Len(line))
End If
End If
End Function
Function FindFontSize(line As String)
Dim size As Integer
Dim space As Integer
size = InStr(size + 1, line, "size=", vbTextCompare)
If (size > 0) Then
space = InStr(size + 1, line, " ", vbTextCompare)
If (space > size) Then
FindFontSize = Mid(line, size + 5, (space) - (size + 5))
Else
FindFontSize = Mid(line, size + 5, Len(line))
End If
End If
End Function
Please if you know something to help then send it.
This web control , would be published as open source and totally free when it would be finished.
Kostas Botonakis , Greece
