How can i get selected text in web page and put it on textbox?

This is the text that i want to copy.
http://i1059.photobucket.com/albums/t432/doomhades666/1-1.png

This the page source of the web page

<div class="output">



<h1 class="titlebar">Calculator Output</h1>



<div style="padding: 1.2ex;">



<pre>Simplifying
-2x + 3y = 8

Solving
-2x + 3y = 8

Solving for variable 'x'.

Move all terms containing x to the left, all other terms to the right.

Add '-3y' to each side of the equation.
-2x + 3y + -3y = 8 + -3y

Combine like terms: 3y + -3y = 0
-2x + 0 = 8 + -3y
-2x = 8 + -3y

Divide each side by '-2'.
x = -4 + 1.5y

Simplifying
x = -4 + 1.5y</pre>

</div>



<div class="status">

Processing time: 1 ms.

26878127 equations since February 08, 2004.

&nbsp; <a href="/calculators/quality.htm">Disclaimer</a>

</div>



</div>

Use regular expresions

Use a .Substring.

Private sMain As String, iSi, iEi As Integer
    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        sMain = "abcd<pre>some calculation here</pre>efg" '// your html.source.
        iSi = sMain.IndexOf("<pre>") + 5 '// locate your start.point.
        iEi = sMain.IndexOf("</pre>", iSi) '// locate end.point.
        MsgBox(sMain.Substring(iSi, iEi - iSi)) '// get results.
    End Sub

How about the red highlighted part of that site is I want to display on my webbrowser when i click button 1 or solve button?

This is the picture of the site that i want to display on my webbrowser.
[IMG]http://i1059.photobucket.com/albums/t432/doomhades666/2.png[/IMG]

This is my code

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        WebBrowser1.Navigate("http://www.algebrahelp.com/calculators/equation/")
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        WebBrowser1.Document.GetElementById("equation").SetAttribute("value", TextBox1.Text)
        WebBrowser1.Document.GetElementById("solvf").SetAttribute("value", ComboBox1.Text)
        WebBrowser1.Document.GetElementById("equationForm").InvokeMember("submit")

    End Sub
End Class

If you just need to change the content of the WebBrowser with yours Then check out this post.

Thanks codeorder for the replies but i want to display that highlighted one in my webbrowser, is that possible? its not an image. its the result of the problem that i made, its a generated answer to the math problem.

See if this helps.

Public Class Form1
    Private urlMain As String = "http://www.algebrahelp.com/calculators/equation/"
    Private sMain, arContent() As String, iSi, iEi As Integer

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        WebBrowser1.Navigate(urlMain)
    End Sub

    Private Sub WebBrowser1_DocumentCompleted(sender As System.Object, e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
        With WebBrowser1
            TextBox2.Text = .Url.AbsoluteUri
            If .Url.AbsoluteUri = urlMain Then '// check if correct.url.
                With .Document
                    .GetElementById("equation").SetAttribute("value", TextBox1.Text)
                    .GetElementById("solvf").SetAttribute("value", ComboBox1.Text)
                    .GetElementById("equationForm").InvokeMember("submit")
                End With
            End If
            If .Url.AbsoluteUri.StartsWith(urlMain) AndAlso .Url.AbsoluteUri.Length > urlMain.Length Then
                sMain = .Document.Body.InnerHtml  '// your html.source.
                If sMain.Contains("<PRE>") Then
                    iSi = sMain.IndexOf("<PRE>") + 5 '// locate your start.point.
                    iEi = sMain.IndexOf("</PRE>", iSi) '// locate end.point.
                    arContent = sMain.Substring(iSi, iEi - iSi).Split(vbCrLf) '// .Split content to get lines.
                    sMain = ""
                    For Each itm As String In arContent '// loop thru all lines of content.
                        If Not sMain = "" Then sMain &= "<br />" & itm Else sMain = itm '// add "<br />" for the wb to recognize it as a new.line.
                    Next
                    .DocumentText = "<div style=""font-family:Verdana;font-size:14px;""><hr />" & sMain & "<hr /></div>" '// get results.
                End If
            End If
        End With
    End Sub
End Class

.btw, I cannot get the answer for "1+1" on that page:(; care to help me in Return and let me know the answer?since I've been trying to figure that out for years.
Thanks in advance.

Many thanks! your the man!.hehe

Glad I could help.:)

I did realize something just now, Not late last night(actually early morning:D) when I previously posted.

Instead of adding and using the arContent() to add line.breaks to the html, it can all be done w/the .Replace.

If .Url.AbsoluteUri.StartsWith(urlMain) AndAlso .Url.AbsoluteUri.Length > urlMain.Length Then
                sMain = .Document.Body.InnerHtml  '// your html.source.
                If sMain.Contains("<PRE>") Then
                    iSi = sMain.IndexOf("<PRE>") + 5 '// locate your start.point.
                    iEi = sMain.IndexOf("</PRE>", iSi) '// locate end.point.
                    .DocumentText = "<div style=""font-family:Verdana;font-size:14px;""><hr />" & sMain.Substring(iSi, iEi - iSi).Replace(vbCrLf, "<br />") & "<hr /></div>" '// get results.
                End If
            End If
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.