Capture URL with Visual basic.net 2008

August 18, 2009 at 15:54:07
Specs: Windows Vista

I can't seem to find a way to get my URL variable to hold the url of the internet explorer window i have opened..... any ideas why?


Here is my code so far:

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim Text As String = ""
Dim Webbrowser1 As Object
Dim url As String

Webbrowser1 = CreateObject("InternetExplorer.Application")
Webbrowser1.visible = True
Webbrowser1.Navigate("Http://www.facebook.com")


Do Until (Webbrowser1.busy = False)
Loop

Line2:

Dim PauseTime1 As Long = 1
Do Until (PauseTime1 = 400000000)
PauseTime1 = PauseTime1 + 1
Loop


url = 'Here!!!!
MsgBox(url)

If url = ("http://www.facebook.com/") Then
Else
GoTo Line2
End If


My.Computer.Keyboard.SendKeys("{Tab 14}")
My.Computer.Keyboard.SendKeys("Email")
My.Computer.Keyboard.SendKeys("{Tab}")
My.Computer.Keyboard.SendKeys("Password")
My.Computer.Keyboard.SendKeys("{enter}")


End Sub
End Class


See More: Capture URL with Visual basic.net 2008

Report •


#1
August 20, 2009 at 05:58:05
My.Computer.Keyboard.SendKeys("{Tab 14}")
My.Computer.Keyboard.SendKeys("Email")
My.Computer.Keyboard.SendKeys("{Tab}")
My.Computer.Keyboard.SendKeys("Password")
My.Computer.Keyboard.SendKeys("{enter}")

Don't do this; it's buggy and breaks if the user clicks the mouse or hits a key. Internet Explorer exposes the DOM to you, so use that instead.

Do Until (Webbrowser1.busy = False)
Busy is only True when IE is rendering something. If it's still waiting for data, this will read False and you'll break out of the loop early. Your best bet would be to test for Webbrowser1.Busy = False And Webbrowser1.readystate = 4

Dim PauseTime1 As Long = 1
Do Until (PauseTime1 = 400000000)
PauseTime1 = PauseTime1 + 1
Loop

Use System.Threading.Thread.Sleep() instead.

GoTo Line2
Don't use GoTo; there are better flow control structures out there. Like Do Loop . . . Until

url = 'Here!!!!
Is Webbrowser1.LocationURL not working?


Report •
Related Solutions


Ask Question