I have grabbed the text from a webpage, and put it into a TextBox using:

TextBox1.Text = WebBrowser1.Document.Body.InnerText

Now in that text box, I have :

Show Me HowDevice Status
ORDER CARTRIDGE LESS THAN 700 PAGES
Help
Pause/Resume     Continue

I want to be able to grab the "ORDER CARTRIDGE LESS THAN 700 PAGES" from the textbox, and put it as the text to TextBox2.Text I have been looking for ways to do this, but I'm just not finding any resolution. This is the simplest amount of text I can get the page down to. This text can also change depending on the printer's status. So I'm basically looking for a way to get the data between Status and Help, and assign it to another textbox's text. I hope this makes sense... If it's easier to get it from the HTML please assist me with that. Below is some of the code from the HTML of the page.

<div  id="Text1"  style="font-size:14px; padding-top: .7em; padding-bottom: .7em;" >ORDER CARTRIDGE
LESS THAN 700 PAGES
</div>
有帮助吗?

解决方案

To answer your specific question:

If you have a good reason to display the whole text in textbox1, and the string you require is always the second line:

TextBox2.Text = Textbox1.Lines(1)

To get direct from the browser:

TextBox2.Text = WebBrowser1.Document.GetElementById("Text1").InnerText

But as the others have mentioned, there are probably better ways to accomplish your task. What exactly are you trying to do?

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top