-
Jul 3rd, 2014, 08:56 AM
#1
Thread Starter
Addicted Member
Webbrowser1 - Copy specific text automatically
Good Morning,
How do I copy a specific text when a page loads to a textbox?
I tried the following:
Code:
Private Sub copybw()
WebBrowser1.Document.ExecCommand("Copy", False, Nothing)
If Clipboard.ContainsText Then
TextBox10.Text = Clipboard.GetText()
End If
End Sub
Code:
Private Sub try1()
Dim bodytext As String
bodytext = WebBrowser1.Document.Body.InnerHtml
If bodytext Like ("###*") Then
copybw()
End If
End Sub
Code:
Private Sub WebBrowser1_DocumentCompleted(sender As Object, e As WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
If Me.WebBrowser1.Document.Body.InnerHtml.Contains("BW") Then
try1()
End If
-
Jul 3rd, 2014, 09:08 AM
#2
Re: Webbrowser1 - Copy specific text automatically
Could try something like this:
Code:
Dim sourceString = "This is a test"
Dim searchString = "test"
Dim index As Integer = sourceString.IndexOf(searchString)
If index <> -1 Then
Dim theStringValueYouWant = sourceString.Substring(index, searchString.Length)
End If
SourceString would be the textbox text, or the string you want to look through. You then see if your search string occurs in that string, if so, you can get the index, and from there use .substring() to pull from that point, to the length of the string. However, at that point you could just use .Contains() if you didnt need the value. It sounds like you are asking because you need to pull items before or after the actual occurence.
Code:
Dim sourceString = "This is a test12345"
Dim searchString = "test"
Dim index As Integer = sourceString.IndexOf(searchString)
If index <> -1 Then
Dim theStringValueYouWant = sourceString.Substring(index + searchString.Length, 5)
End If
In this scenario, you have a group of numbers that occur after Test. This shows you how you could pull those numbers since you may not know what they will be, but you know where they will occur.
-
Jul 3rd, 2014, 12:44 PM
#3
Thread Starter
Addicted Member
Re: Webbrowser1 - Copy specific text automatically
thank you, testing it now.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|