Advertisement
TheVideoVolcano

Get String Between Characters (Tags)

Dec 26th, 2013
348
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.75 KB | None | 0 0
  1. Public Class Form1
  2.     Private sessionKey as string = nothing
  3.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  4.    
  5.    
  6.         sessionKey = GetStringBetweenTags("<session_key>", "</session_key>", textbox1.text)
  7.  
  8.  
  9.     End Sub
  10.    
  11.     Private function GetStringBetweenTags(ByVal startIdentifer As String, ByVal endIndentifier As String, ByVal textsource As String) as string
  12.         Dim idLength As Int16 = startIdentifer.Length
  13.  
  14.         Dim s As String = textsource
  15.  
  16.         Try
  17.  
  18.             s = s.Substring(s.IndexOf(startIdentifer) + idLength)
  19.             s = s.Substring(0, s.IndexOf(endIndentifier))
  20.             'MsgBox(s)
  21.  
  22.         Catch
  23.         End Try
  24. return s
  25.     End Sub
  26. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement