A1VBCode Forums

How to determine the Url of the current Webbrowser page.


http://www.a1vbcode.com/vbforums/Topic32021.aspx

By tonyallan8128 - 6/28/2013

I am writing some code to navigate to a particular web page determined by the current page webbrowser1 is on.

That is, if it was on one page go to a certain page, but if it was on another page go to a different page.

So I need to be able to return the URL of the current page in webbrowser1.



What do i put in the messagebox.show field to display current web page?



Any help would be appreciated.





*********************************************************************



Imports System.Net 'For webrequest and webresponce

Imports System.IO ' To read data stream





Public Class Form1



Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim i As Integer

Dim UserID As String = "user id"

Dim Password As String = "user password"





'This logs on to Site and enters User ID, Password



WebBrowser1.Navigate("web page")

For i = 1 To 300000000

Next

Do While WebBrowser1.ReadyState <> WebBrowserReadyState.Complete

Application.DoEvents()

Loop



'Inputs ID

WebBrowser1.Document.GetElementById("UserID").SetAttribute("Value", UserID)



'Inputs Password

WebBrowser1.Document.GetElementById("Password").SetAttribute("Value", Password)



'Submits information

WebBrowser1.Document.GetElementById("LogonForm").InvokeMember("submit")

For i = 1 To 300000000

Next



MessageBox.Show(WebBrowser1.Url) 'this brings System.Uri can not convert to string.







End Sub

End Class
By tonyallan8128 - 7/2/2013

MessageBox.Show(WebBrowser1.Url.ToString)