对非共享成员的引用需要对象引用

时间:2012-11-23 03:26:38

标签: regex visual-studio vb.net-2010

我正在尝试从列表框中删除一些文本,但我一直收到此错误。

Error   1   Reference to a non-shared member requires an object reference.  

这是导致错误的代码。

ListBox1.Items.Add(Match.ToString.Replace("color: 0863BB;", "").Replace("</span>", "").Replace(">", "").Replace("""", ""))

这是我的完整代码。 我不知道我做错了什么,请帮忙。

Imports System.Text.RegularExpressions

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim Regex As New Regex("color: 0863BB;" & Chr(34) & ">(.*?)</span></span>")
    Dim Matches As MatchCollection = Regex.Matches(RichTextBox1.Text)

    For Each Match As Match In Matches

        ListBox1.Items.Add(Match.ToString)

    Next

End Sub

Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
    'RichTextBox1.Text = WebBrowser1.DocumentText

End Sub

Private Sub RichTextBox1_TextChanged(sender As System.Object, e As System.EventArgs) Handles RichTextBox1.TextChanged
    ListBox1.Items.Add(Match.ToString.Replace("color: 0863BB;", "").Replace("</span>", "").Replace(">", "").Replace("""", ""))
End Sub

Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click
    If ListBox1.Items.Contains("<span>") Then

    End If
End Sub

Private Sub ListBox1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
    '  (Match.ToString.Replace("color: 0863BB;", "").Replace("</span>", "").Replace(">", "").Replace("""", ""))
End Sub

结束班

1 个答案:

答案 0 :(得分:1)

编译器抱怨Match.ToStringToString是一种实例方法,但Match是一种类型。