5 Replies - 625 Views - Last Post: 10 October 2009 - 06:51 PM Rate Topic: -----

#1 kryton46  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 6
  • View blog
  • Posts: 44
  • Joined: 29-December 08

Help needed with one line of code - WeBrowser

Posted 10 October 2009 - 03:16 PM

This is really frustrating me, because i can't seem to replicate the error every time and it's only one line of code. :crazy:

I wanted to see if i could load up a YouTube page and found this test video page from Google's API site.

Using VS 2008, i create a very simple project that contains just a WebBrowser. I want to load the page when the form loads:

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
		WebBrowser1.Navigate("http://code.google.com/apis/youtube/js_example_1.html")
End Sub



Every now & then (occurs once every 3-5 times, but varies), the form just shows a blank white box.

Could someone help me understand why this happens please.

I tried to use a timer (interval set to 1000), to stop the browser and reload the page, but it never seems to fire up if the white box error occurs:



 Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
		Timer1.Enabled = True
		WebBrowser1.Navigate("http://code.google.com/apis/youtube/js_example_1.html")
	End Sub

Private _secondCounter As Integer = 0
	Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
		If _secondCounter = 3 Then
			If WebBrowser1.IsBusy Then
				WebBrowser1.Stop()
				WebBrowser1.Navigate("http://code.google.com/apis/youtube/js_example_1.html")
			End If
		Else
			Timer1.Enabled = False
		End If
		_secondCounter += 1
	End Sub



Thanks in advance for any help.

This post has been edited by kryton46: 10 October 2009 - 03:17 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Help needed with one line of code - WeBrowser

#2 gbertoli3  Icon User is offline

  • DIC at Heart + Code
  • member icon

Reputation: 40
  • View blog
  • Posts: 1,162
  • Joined: 23-June 08

Re: Help needed with one line of code - WeBrowser

Posted 10 October 2009 - 05:12 PM

Try using Timer1.Start()
Was This Post Helpful? 0
  • +
  • -

#3 Spiralz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 30-March 09

Re: Help needed with one line of code - WeBrowser

Posted 10 October 2009 - 05:53 PM

View Postgbertoli3, on 10 Oct, 2009 - 08:12 PM, said:

Try using Timer1.Start()


That won't help, .Start just sets .Enabled to true, which is what he's already doing.
Was This Post Helpful? 0
  • +
  • -

#4 kryton46  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 6
  • View blog
  • Posts: 44
  • Joined: 29-December 08

Re: Help needed with one line of code - WeBrowser

Posted 10 October 2009 - 06:25 PM

This is most strange, as the freeze happens even if i load any page like http://google.com.

I thought it was to do with the fact i was placing WebBrowser1.Navigate("http://google.com") in the Form load event and so the control hadn't yet initialised properly.

However, i have nothing now in my Form load and instead added a button and added this code:

Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		WebBrowser1.Navigate("http://google.com")
End Sub



Again, this works for most of the time, but occasionally it freezes and shows the hour glass on the cursor and just freezes.

Do you think this is a M$ bug.

Thanks in advance.

p.s. can anyone else replicate this; you'll have to start-stop the app a few times in succession to get the freeze.
Was This Post Helpful? 0
  • +
  • -

#5 gbertoli3  Icon User is offline

  • DIC at Heart + Code
  • member icon

Reputation: 40
  • View blog
  • Posts: 1,162
  • Joined: 23-June 08

Re: Help needed with one line of code - WeBrowser

Posted 10 October 2009 - 06:46 PM

Try adding a button to the form; and see if on the Click event of the button if you can navigate to a website.
Was This Post Helpful? 0
  • +
  • -

#6 gbertoli3  Icon User is offline

  • DIC at Heart + Code
  • member icon

Reputation: 40
  • View blog
  • Posts: 1,162
  • Joined: 23-June 08

Re: Help needed with one line of code - WeBrowser

Posted 10 October 2009 - 06:51 PM

Try adding a button to the form; and see if on the Click event of the button if you can navigate to a website.

This post has been edited by gbertoli3: 11 October 2009 - 10:03 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1