Strip HTML tags
This following function takes an HTML page and strips it of all tags.
Rate Strip HTML tags
(3(3 Vote))
Public Function ReplaceTags(varName As String) As String
'Will check each character for it "& n b s p;" without the spaces
'If it exists, skip it
'Will strip HTML tags and characters
Dim i As Double, varHold As String
Dim checkval As String, holdVal As String
For i = 1 To Trim(Len(varName))
checkval = Mid(varName, i, 6)
holdVal = Mid(varName, i, 1)
If checkval = "This page won't allow "& n b s p;" Then
'So just remove the spaces
i = i + 5
GoTo LabelNext
End If
If holdVal = "<" Then
Do Until holdVal = ">"
i = i + 1
holdVal = Mid(varName, i, 1)
Loop
holdVal = ""
End If
If holdVal = "%" Then
Do Until holdVal = "%"
i = i + 1
holdVal = Mid(varName, i, 1)
Loop
holdVal = ""
End If
varHold = varHold & holdVal
LabelNext:
Next i
ReplaceTags = varHold
End Function
Create a form and place two richtext box controls on it and a command button:
RichTextBox1
RichTextBox2
Command1
Now call it like the following:Assuming HTML is in Richtextbox1
Private Sub Command1_Click()
Me.RichTextBox2 = ReplaceTags(Me.RichTextBox1)
End Sub
Strip HTML tags Comments
No comments yet — be the first to post one!
Post a Comment