I want to outpout part of a richtextbox content to a textbox.

Exemple (This is just part of the richboxtext1:

<meta http-equiv="refresh" content="0;url=?sid=defd7592f5b806ad8a4fa1273bd73077">		<

This is code i used but is faulty :(
:

Dim strBuild As String = Nothing
        strBuild = Split(Split(RichTextBox1.Text, "sid=")(1), "''>")(0)

        TextBox6.Text = strBuild

I want whats between "sid=" and the "''>"
sid=defd7592f5b806ad8a4fa1273bd73077">

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

This only copies:

h" content="0;url=?

From:

<meta http-equiv="refresh" content="0;url=?sid=defd7592f5b806ad8a4fa1273bd73077">

Note that i did edit the tags to "sid=" and "''>"

Dim strS As String() = Nothing
            Dim actaulstring As String = ""
            strS = RichTextBox1.Text.Split("=")
            actaulstring = strS.GetValue(2)
            strS = actaulstring.Split(">")
            actaulstring = strS(0)
            TextBox2.Text = actaulstring

Same thing as before it splits to "h" content="0;url=?"

It didnt let me edit the post above, i totally forgot the code is multi line and has many other codes above the ling i posted.

so it slike

blah blah blahblah blah blahblah blah blah
blah blah blahblah blah blahblah blah blah
blah blah blahblah blah blahblah blah blah
<meta http-equiv="refresh" content="0;url=?sid=defd7592f5b806ad8a4fa1273bd73077">
blah blah blahblah blah blahblah blah blah
blah blah blahblah blah blahblah blah blah
blah blah blahblah blah blahblah blah blah

blah blah blahblah blah blahblah blah blah
blah blah blahblah blah blahblah blah blah
blah blah blahblah blah blahblah blah blah

And it aint always on the 4th line can be further or before.

Dim start As Integer = 1
            Dim F1 As Integer
            Dim F2 As Integer
            F1 = InStr(start, RichTextBox1.Text, "sid=")
            F2 = InStr(F1 + 1, RichTextBox1.Text, """>")
            If F2 = 0 Then F2 = Len(RichTextBox1.Text)
            TextBox6.Text = (Mid(RichTextBox1.Text, F1, F2 - F1))

Solved.

Not really sure, but I believe that "Len" is from vb6 and might cause issues in the future when used as code in vb.net.
If "Len" is length, then use RichTextBox1.Text.Length .

As for your already solved issue, see if this helps.

Dim iStartIndex, iEndIndex As Integer
        With RichTextBox1.Text
            iStartIndex = .IndexOf("sid=") + 4
            iEndIndex = .IndexOf(""">", iStartIndex)
            MsgBox(.Substring(iStartIndex, iEndIndex - iStartIndex))
        End With
commented: Thnx +1

Oh wow this works perfect, thanks coderorder.

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.