Read between strings

Do you need something made? then ask in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
4 posts Page 1 of 1
Contributors
User avatar
M1z23R
VIP - Donator
VIP - Donator
Posts: 622
Joined: Tue Sep 28, 2010 4:55 pm

Read between strings
M1z23R
I need help reading string between strings xD for example "</xx>TEXT<xx/>
i want to read the "TEXT" between these two :)
User avatar
Scottie1972
Codenstuff Elite
Codenstuff Elite
Posts: 953
Joined: Thu Jan 14, 2010 5:48 am

Re: Read between strings
Scottie1972
WebBrowser1.Document.getElementByTagName
Code: Select all
Private Sub DisplayMetaDescription()
    If (WebBrowser1.Document IsNot Nothing) Then
        Dim Elems As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("META")

        For Each elem As HtmlElement In Elems
            Dim NameStr As String = elem.GetAttribute("name")

            If ((NameStr IsNot Nothing) And (NameStr.Length <> 0)) Then
                If NameStr.ToLower().Equals("description") Then
                    Dim ContentStr As String = elem.GetAttribute("content")
                    MessageBox.Show("Document: " & WebBrowser1.Url.ToString() & vbCrLf & "Description: " & ContentStr)
                End If
            End If
        Next
    End If
End Sub
WebBrowser1.Document.getElementById
Code: Select all
Private Function GetTableRowCount(ByVal TableID As String) As Integer
    Dim Count As Integer = 0

    If (WebBrowser1.Document IsNot Nothing) Then

        Dim TableElem As HtmlElement = WebBrowser1.Document.GetElementById(TableID)
        If (TableElem IsNot Nothing) Then
            For Each RowElem As HtmlElement In TableElem.GetElementsByTagName("TR")
                Count = Count + 1
            Next
        Else
            Throw (New ArgumentException("No TABLE with an ID of " & TableID & " exists."))
        End If
    End If
    GetTableRowCount = Count
End Function
Image
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: Read between strings
mandai
It isn't clear how we would use the code above to get a substring.

You could use this:
Code: Select all
        Dim input As String = "</xx>TEXT<xx/>"
        Dim text As String = input.Remove(0, input.IndexOf(">"c) + 1)
        text = text.Remove(text.IndexOf("<"c))

        MsgBox(text)
User avatar
M1z23R
VIP - Donator
VIP - Donator
Posts: 622
Joined: Tue Sep 28, 2010 4:55 pm

Re: Read between strings
M1z23R
Thanks guys :)
4 posts Page 1 of 1
Return to “Tutorial Requests”