0

如果 html id 是,可以说“ex_a1”、“ex_a2”、“ex_a3”等。你可以只使用第 5 个字母作为参考吗?

也许像这样?

`Dim 元素 = WebBrowser1.Document.GetElementsByTagName("a")

    For Each element As HtmlElement In elements

        If element.GetAttribute("className") = "EXAMPLE" Then
            If 5TH_LETTER_OF_ID = UserChoice then 
            element.InvokeMember("click")
            Exit For
          End If
        End If
    Next`

UserChoice 是 0 到 16 之间的数字

4

1 回答 1

0

尝试使用类的Contains方法String,如下所示:

If element.Id.ToString().Contains(UserChoice) Then
    ' Put logic here if there is a match
End If
于 2013-07-29T20:58:44.113 回答