ConvertHTMLtoText 簡易標註語言轉一般文字 VB2017

點閱: 90

目的是為了將 自寫的 郵件收件程式 收到郵件內文轉成可閱讀的文字與列印
如此可將特定的訂單 自動列印
Public Class Form1
Dim startVariable As Integer
Dim endVariable As Integer
Dim varName As String
‘ *************************************************************************************
‘ 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, ”>”, ””)
strHTML = Replace(strHTML, ”<”, ””)
strHTML = Replace(strHTML, ” ”, ””)

ConvertHTMLtoText = strHTML
End Function

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
TextBox1.Text = ConvertHTMLtoText(TextBox1.Text)
End Sub
End Class

發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *