WORKING WITH QTP

TestEveryThinG

Convert HTML text to Simple text VB Script

Posted by rajivkumarnandvani on November 6, 2009

Hi All,

Some time we required HTML text change to simple text here i created a function which will convert your HTML text to simple readable text.

‘ *************************************************************************************
‘ Function Name:    ConvertHTMLtoText
‘ Description:        This function is used to convert HTML string to Simple Text
‘ Arguments:        HTML string

‘ Return Value:        SimpleText
‘‘Syntax of calling the defined function:    Call  ConvertHTMLtoText(strHTML)
‘ *************************************************************************************

Public Function ConvertHTMLtoText(byVal strHTML)
If InStr(1,strHTML,”<“) > 0 Then
Do
startVariable = InStr(1,strHTML,”<“)

endVariable = InStr(startVariable,strHTML,”>”)
varName = Mid(strHTML,startVariable, endVariable-startVariable+1)
strHTML = replace(strHTML,varName,””)
Loop While InStr(1,strHTML,”<“) > 0
End If
strHTML = replace(strHTML,”&gt;”,””)
strHTML = replace(strHTML,”&lt;”,””)
ConvertHTMLtoText = strHTML
End Function

msgbox ConvertHTMLtoText(“<br><br><font color=””””#008000″”””>TestingGUID position 26 with dashes must be one of the following: AB234567</font></body></html>”)

Leave a comment