user3362189 user3362189 - 4 months ago 18 Question

VB.NET get between all strings one by one

so this code checks only once between

Private Function GetBetween(ByVal sSearch As String, ByVal sStart As String, _
ByVal sStop As String, Optional ByVal lSearch As Integer = 1) As String
Dim lTemp As Long

lSearch = InStr(lSearch, sSearch, sStart)
If lSearch > 0 Then
lSearch += Len(sStart)
lTemp = InStr(lSearch, sSearch, sStop)
If lTemp > lSearch Then
GetBetween = Trim(Mid(sSearch, lSearch, lTemp - lSearch))
End If
End If
End Function

i got this string the string is not stable i mean there can be more players then this and i want to show the text between player /player one by one for example in messagebox.
sorry for my english


Use the correct tool to parse XML, System.Xml.XmlDocument:

' Add the namespace at the top
Imports System.Xml
' And then ...
Dim sXml As String = "YOUR_XML_STRING_HERE"
Dim doc As New XmlDocument
doc.PreserveWhitespace = True
For Each Entry As XmlNode In doc.SelectNodes("//player")

See the VB.NET demo here.

If you do not need the tags to be shown, replace Entry.InnerXml with Entry.InnerText.

Note that the //player is an XPath expression that gets all <player> nodes.