VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



HTML toText

by Sergio P (1 Submission)
Category: Internet/HTML
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (4 Votes)

This little piece of code will strip all HTML tags from a web page. What your left with is pure text.

I've seen a few approaches, one which took up 500 lines of code. And some guy is selling an HTML stripper for $250. Rediculous.
This is my first post here. I just wanted to share and save someone some time.

Assumes
Just paste it into your form or module and call it. Text1 = HTML2Text(HTMLString1)

Rate HTML toText

Public Function HTML2Text(ByVal HTML As String) As String
Dim X As Long
Dim B As String
Dim String1 As String
Dim Counter As Long
X = 1
B$ = Mid(HTML, X, 1)
While Len(B$) = 1
B$ = Mid(HTML, X, 1)
If B$ = "<" Then Counter = Counter + 1
If Counter = 0 Then String1$ = String1$ + B$
If B$ = ">" And Counter <> 0 Then Counter = Counter - 1
X = X + 1
Wend
HTML2Text = String1
End Function

Download this snippet    Add to My Saved Code

HTML toText Comments

No comments have been posted about HTML toText. Why not be the first to post a comment about HTML toText.

Post your comment

Subject:
Message:
0/1000 characters