Async Sub InitializeAsync() Await WebView2.EnsureCoreWebView2Async(Nothing) End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load '初期化 InitializeAsync() End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) End Sub Button1.Click 'サイトを開く WebView2.CoreWebView2.Navigate(TargetURL2) End Sub
Module Hensu 'パブリック変数宣言 Public intNavigationState As Integer End Module
Private Sub WebView2_NavigationStarting(sender As Object, e As CoreWebView2NavigationStartingEventArgs) Handles WebView2.NavigationStarting intNavigationState = 0 'サイト表示開始 End Sub
Private Sub WebView2_NavigationCompleted(sender As Object, e As CoreWebView2NavigationCompletedEventArgs) Handles WebView2.NavigationCompleted intNavigationState = 1 'サイト表示完了 End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) End Sub Button2.Click Dim strResponse As String If intNavigationState = 1 Then 'URLを取得する。 strResponse=WebView2.CoreWebView2.Source End If End Sub