ssoni

webBrowserVB

Mar 4th, 2026
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.69 KB | None | 0 0
  1. Imports Microsoft.Web.WebView2.Core
  2.  
  3. Public Class Form1
  4.     Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  5.         WebBrowser1.Source = New Uri("https://www.google.com")
  6.  
  7.     End Sub
  8.  
  9.     Private Async Sub WebBrowser1_NavigationCompleted(sender As Object, e As CoreWebView2NavigationCompletedEventArgs) Handles WebBrowser1.NavigationCompleted
  10.         Await Task.Delay(1500)
  11.  
  12.         ' Enter "cat" and submit the search
  13.         Dim script As String =
  14.             "document.querySelector('textarea[name=""q""]').value='cat';" &
  15.             "document.querySelector('form').submit();"
  16.  
  17.         Await WebBrowser1.ExecuteScriptAsync(script)
  18.  
  19.     End Sub
  20.  
Advertisement
Add Comment
Please, Sign In to add comment