Reputation:
I'm trying to remove img files from webbrowser1 control.
This is what I did.
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
Dim origHTML As String
origHTML = WebBrowser1.DocumentText
Dim newHTML As String
Dim regex As String = "<img.*/>"
newHTML = regex.Replace(origHTML, regex, "", RegexOptions.Multiline)
WebBrowser1.DocumentText = newHTML
WebBrowser1.ScriptErrorsSuppressed = True
End Sub
I'm getting 'Overload resolution failed because no accessible 'Replace' accepts this number of arguments' error. Any advice, please.
Upvotes: 0
Views: 511
Reputation: 1274
You're using String's Replace, not the Regex object's Replace.
Try this:
Dim pattern As String = "<img.*/>"
newHTML = Regex.Replace(origHTML, pattern, "", RegexOptions.Multiline)
I'm not sure if that Regex pattern will work though, but that should fix the overload error.
Upvotes: 0