If you add a link to System.Web in your project, you can use the following to encode the html string
Dim strEncUsername As String = System.Web.HttpUtility.HtmlEncode(Me.txtUsername.Text)
MSDN Documentation for HttpUtility.HtmlEncode
Edit
Screenshot with intellisense showing HtmlEncode:

Screenshot in the project:

Exit the application:
unsafe text: <em>evil em tags within</em> safe text: <em>evil em tags within</em>
source share