954,541 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Copy part of text from richtextbox (Split)

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">

AnooooPower
Newbie Poster
21 posts since Feb 2011
Reputation Points: 10
Solved Threads: 0
 
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
Pgmer
Master Poster
714 posts since Apr 2008
Reputation Points: 54
Solved Threads: 121
 

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 "''>"

AnooooPower
Newbie Poster
21 posts since Feb 2011
Reputation Points: 10
Solved Threads: 0
 
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
Pgmer
Master Poster
714 posts since Apr 2008
Reputation Points: 54
Solved Threads: 121
 

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

AnooooPower
Newbie Poster
21 posts since Feb 2011
Reputation Points: 10
Solved Threads: 0
 

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.

AnooooPower
Newbie Poster
21 posts since Feb 2011
Reputation Points: 10
Solved Threads: 0
 
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.

AnooooPower
Newbie Poster
21 posts since Feb 2011
Reputation Points: 10
Solved Threads: 0
 

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
codeorder
Posting Virtuoso
1,915 posts since Aug 2010
Reputation Points: 255
Solved Threads: 384
 

Oh wow this works perfect, thanks coderorder.

AnooooPower
Newbie Poster
21 posts since Feb 2011
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: