I have textbox--
(texbox1)= aaa bbb ccc <e2>code</e2> aaa bbb ccc
just i want (textbox2)= I want the code between <e2> and </e2> the code
Where the code is a variable

Dim strS As String() = Nothing
            Dim actaulstring As String = ""
            strS = TextBox1.Text.Split(">")
            actaulstring = strS.GetValue(1)
            strS = actaulstring.Split("<")
            actaulstring = strS(0)

hello,
i am still newbie to vb.net, but had a general idea.. so i thought i will post

Dim tag1 As String = Textbox1.text.Replace("<e2>", "^")
        Dim tag2 As String = tag1.Replace("</e2>", "`")
        Dim Position1 As Integer = tag2.LastIndexOf("^") + 1
        Dim Position2 As Integer = tag2.LastIndexOf("`") - 1
        Dim code As String = tag2.Substring(Position1,Position2)
        MessageBox.Show(code)
commented: "The best way to learn, is to help others." quoted from my experience. +1

Also, see if this helps to extract data from a String or .Text.

With TextBox1
            .Text = "aaa bbb ccc <e2>code</e2> aaa bbb ccc"
            Dim iStartIndex As Integer = .Text.IndexOf("<e2>") + 4 '// +4 to exclude the "<e2>" characters.
            '// .IndexOf(char./string to locate, Start search from this Index.)
            Dim iEndIndex As Integer = .Text.IndexOf("</e2>", iStartIndex)
            '// .Substring(Start Index of Substring, length of Substring to extract)
            TextBox2.Text = TextBox1.Text.Substring(iStartIndex, iEndIndex - iStartIndex) & "order :D"
        End With

Not to beat a dead horse, but I'm surprised no one mentioned Regular Expressions

Imports System.Text.RegularExpressions

Module Module1
   Sub Main()
      Dim strTextBoxText As String = "asdf asdf <e2>code</e2> asdf asdf"
      Dim strCode As String = "Not Found"
      Dim rxE2 = New Regex("<e2>(?<target>.*)</e2>")
      '
      If rxE2.IsMatch(strTextBoxText) Then
         strCode = rxE2.Match(strTextBoxText).Groups("target").Value
      End If
      ' ...and if this is a console test...
      ' Console.WriteLine(strCode)
   End Sub
End Module
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.