Making Web Browser Need Help

Need Help making web browser

Page 1 of 1

6 Replies - 3963 Views - Last Post: 25 July 2008 - 05:31 PM Rate Topic: -----

#1 sbh  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 23-July 08

Making Web Browser Need Help

Post icon  Posted 23 July 2008 - 03:57 PM

Making Web Browser need help with errors. New at this so be patient thanks!

Public Class Form1

    Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        WebBrowser1.GoBack()
    End Sub
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        WebBrowser1.GoForward()
    End Sub

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

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        WebBrowser1.Navigate(TextBox1.Text)
    End Sub

    Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
    End Sub

    Private Sub FileToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FileToolStripMenuItem.Click
    End Sub
    Private Sub NewWindowToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewWindowToolStripMenuItem.Click
        Dim f2 As New Form2
        f2.Form1.Navigate("http://www.sbhweb.co.nr")
        f2.Form1.Show()
    End Sub
    Private Sub printToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _Handles printToolStripMenuItem.Click
        Form1.print()
    End Sub
    Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
        End
    End Sub
    Private Sub CutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CutToolStripMenuItem.Click
    End Sub

    Private Sub CopyToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopyToolStripMenuItem.Click
    End Sub

    Private Sub PasteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PasteToolStripMenuItem.Click
    End Sub

    Private Sub SelectAllToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SelectAllToolStripMenuItem.Click
    End Sub

    Private Sub SourceToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SourceToolStripMenuItem1.Click
        Me.Show()
    End Sub
    Private Sub FullScreenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FullScreenToolStripMenuItem.Click
    End Sub
    Private Sub Form1_ProgressChanged(ByVal sender As Object, _
    ByVal e As System.Windows.Forms.WebBrowserProgressChangedEventArgs) Handles WebBrowser.ProgressChanged
        If e.CurrentProgress < e.MaximumProgress Then
            If ToolStripProgressBar1.Value >= ToolStripProgressBar1.Maximum Then
                ToolStripProgressBar1.Value = ToolStripProgressBar1.Minimum
            Else
                ToolStripProgressBar1.PerformStep()
            End If
        Else
            ToolStripProgressBar1.Value = ToolStripProgressBar1.Minimum
        End If
    End Sub
    Private Sub Form1_Load2(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.WindowState = FormWindowState.Maximized
        Me.Controls.Add(TabControl1)
        TabControl1.Dock = DockStyle.Fill
    End Sub

    Private Sub NewTabToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewTabToolStripMenuItem.Click
        Dim tabpage As New TabPage
        Dim Form1 As New WebBrowser
        Form1.Dock = DockStyle.Fill
        AddHandler Form1.Navigating, AddressOf WebBrowser_Navigating
        AddHandler Form1.DocumentCompleted, AddressOf WebBrowser_DocumentCompleted
        tabpage.Controls.Add(tabpage)
        tabpage.Controls.Add(Form1)
        Form1.Navigate("http://www.sbhweb.co.nr")
    End Sub

    Private Sub WebBrowser_Navigating(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserNavigatingEventArgs)
        sender.parent.text = "Loading....."
    End Sub

    Private Sub WebBrowser_DocumentCompleted(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs)
        sender.parent.text = sender.document.Title
    End Sub
    Private Sub CloseTabToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CloseTabToolStripMenuItem.Click
        TabControl1.TabPages.Remove(TabControl1.SelectedTab)
    End Sub
End Class



Errors

* Error 1 Handles clause requires a WithEvents variable defined in the containing type or one of its base types. C:\Documents and Settings\All Users\Documents\SBH-Webs\SBH-Webs\Form1.vb 25 118 SBH-Webs
* Error 2 Type 'Form2' is not defined. C:\Documents and Settings\All Users\Documents\SBH-Webs\SBH-Webs\Form1.vb 26 23 SBH-Webs
* Error 3 Handles clause requires a WithEvents variable defined in the containing type or one of its base types. C:\Documents and Settings\All Users\Documents\SBH-Webs\SBH-Webs\Form1.vb 30 114 SBH-Webs
* Error 4 'print' is not a member of 'SBH_Web.Form1'. C:\Documents and Settings\All Users\Documents\SBH-Webs\SBH-Webs\Form1.vb 31 9 SBH-Webs
* Error 5 Handles clause requires a WithEvents variable defined in the containing type or one of its base types. C:\Documents and Settings\All Users\Documents\SBH-Webs\SBH-Webs\Form1.vb 48 116 SBH-Webs
* Error 6 Handles clause requires a WithEvents variable defined in the containing type or one of its base types. C:\Documents and Settings\All Users\Documents\SBH-Webs\SBH-Webs\Form1.vb 51 119 SBH-Webs
* Error 7 Handles clause requires a WithEvents variable defined in the containing type or one of its base types. C:\Documents and Settings\All Users\Documents\SBH-Webs\SBH-Webs\Form1.vb 54 81 SBH-Webs

Thanks to anyone who can help me!!

Mod Edit: Please use code tags when posting your code. Code tags are used like so => :code:

Thanks,
PsychoCoder :)

Is This A Good Question/Topic? 0
  • +

Replies To: Making Web Browser Need Help

#2 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2263
  • View blog
  • Posts: 9,462
  • Joined: 29-May 08

Re: Making Web Browser Need Help

Posted 23 July 2008 - 04:58 PM

First thing please when including code in your post to enclose it in :code:
Secondly when WebBrowser routines don't have and handles after them or I can't see any AddHandlers.
eg
Private Sub WebBrowser_Navigating(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserNavigatingEventArgs) handles WebBrowser.Navigating
sender.parent.text = "Loading....."
End Sub


Was This Post Helpful? 0
  • +
  • -

#3 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1641
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Making Web Browser Need Help

Posted 23 July 2008 - 04:58 PM

Moved to VB.NET :)
Was This Post Helpful? 0
  • +
  • -

#4 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2263
  • View blog
  • Posts: 9,462
  • Joined: 29-May 08

Re: Making Web Browser Need Help

Posted 23 July 2008 - 05:29 PM

View Postsbh, on 23 Jul, 2008 - 11:57 PM, said:

Making Web Browser need help with errors. New at this so be patient thanks!


Could be that the WebBrowser was Form1, renamed to WebForm1

    Private Sub NewTabToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewTabToolStripMenuItem.Click
        Dim tabpage As New TabPage
        Dim WebForm1 As New WebBrowser
        WebForm1 .Dock = DockStyle.Fill
        AddHandler WebForm1 .Navigating, AddressOf WebBrowser_Navigating
        AddHandler WebForm1 .DocumentCompleted, AddressOf WebBrowser_DocumentCompleted
        tabpage.Controls.Add(tabpage)
        tabpage.Controls.Add(WebForm1 )
        Form1.Navigate("http://www.sbhweb.co.nr")
    End Sub


also
Private Sub NewWindowToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewWindowToolStripMenuItem.Click  
 Dim f2 As New Form2  <- Should it be Form
 f2.Form1.Navigate("http://www.sbhweb.co.nr")  
 f2.Form1.Show()  
End Sub 


Was This Post Helpful? 0
  • +
  • -

#5 sbh  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 23-July 08

Re: Making Web Browser Need Help

Posted 25 July 2008 - 04:48 PM

Alright thanks guys, and does that mean that this was moved to a different location??
Was This Post Helpful? 0
  • +
  • -

#6 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1641
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Making Web Browser Need Help

Posted 25 July 2008 - 04:52 PM

@sbh: Yes I moved this to the VB.NET forum because the code you posted was written in VB.NET and not VB6 (or older) which is what the Visual Basic forum is for :)
Was This Post Helpful? 0
  • +
  • -

#7 sbh  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 23-July 08

Re: Making Web Browser Need Help

Posted 25 July 2008 - 05:31 PM

Alright Got it down to 5 errors now, What I am really stuck with is adding Events to all the places that need it. How do you do that??

Here is what I have now:

Public Class Form1

	Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint
	End Sub
	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		WebBrowser1.GoBack()
	End Sub
	Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
		WebBrowser1.GoForward()
	End Sub

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

	Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
		WebBrowser1.Navigate(TextBox1.Text)
	End Sub

	Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
	End Sub

	Private Sub FileToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FileToolStripMenuItem.Click
	End Sub
	Private Sub NewWindowToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles [u]NewWindoToolStripMenuItem[/u].Click
		Dim f2 As New Form
		WebBrowser1.Navigate("http://www.sbhweb.co.nr")
		f2.Show()
	End Sub
	Private Sub printToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles [u]printToolStripMenuItem[/u].Click
		[u]Form1.print[/u]()
	End Sub
	Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
		End
	End Sub
	Private Sub CutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CutToolStripMenuItem.Click
	End Sub

	Private Sub CopyToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopyToolStripMenuItem.Click
	End Sub

	Private Sub PasteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PasteToolStripMenuItem.Click
	End Sub

	Private Sub SelectAllToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SelectAllToolStripMenuItem.Click
	End Sub

	Private Sub SourceToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles [u]SourceToolStripMenuItem1[/u].Click
		Me.Show()
	End Sub
	Private Sub Form1_ProgressChanged(ByVal sender As Object, _
	ByVal e As System.Windows.Forms.WebBrowserProgressChangedEventArgs) Handles WebBrowser1.ProgressChanged
		If e.CurrentProgress < e.MaximumProgress Then
			If ToolStripProgressBar1.Value >= ToolStripProgressBar1.Maximum Then
				ToolStripProgressBar1.Value = ToolStripProgressBar1.Minimum
			Else
				ToolStripProgressBar1.PerformStep()
			End If
		Else
			ToolStripProgressBar1.Value = ToolStripProgressBar1.Minimum
		End If
	End Sub
	Private Sub Form1_Load2(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
		Me.WindowState = FormWindowState.Maximized
		Me.Controls.Add(TabControl1)
		TabControl1.Dock = DockStyle.Fill
	End Sub

	Private Sub NewTabToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewTabToolStripMenuItem.Click
		Dim tabpage As New TabPage
		Dim Form1 As New WebBrowser
		Form1.Dock = DockStyle.Fill
		AddHandler Form1.Navigating, AddressOf WebBrowser_Navigating
		AddHandler Form1.DocumentCompleted, AddressOf WebBrowser_DocumentCompleted
		tabpage.Controls.Add(tabpage)
		tabpage.Controls.Add(Form1)
		Form1.Navigate("http://www.sbhweb.co.nr")
	End Sub

	Private Sub WebBrowser_Navigating(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserNavigatingEventArgs)
		sender.parent.text = "Loading....."
	End Sub

	Private Sub WebBrowser_DocumentCompleted(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs)
		sender.parent.text = sender.document.Title
	End Sub
	Private Sub CloseTabToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CloseTabToolStripMenuItem.Click
		TabControl1.TabPages.Remove(TabControl1.SelectedTab)
	End Sub
End Class



And here are the errors:

Error	1	Handles clause requires a WithEvents variable defined in the containing type or one of its base types.	C:\Documents and Settings\All Users\Documents\SBH-Webs\SBH-Webs\Form1.vb	25	118	SBH-Webs

Error	2	Handles clause requires a WithEvents variable defined in the containing type or one of its base types.	C:\Documents and Settings\All Users\Documents\SBH-Webs\SBH-Webs\Form1.vb	30	114	SBH-Webs

Error	3	'print' is not a member of 'SBH_Web.Form1'.	C:\Documents and Settings\All Users\Documents\SBH-Webs\SBH-Webs\Form1.vb	31	9	SBH-Webs

Error	4	Handles clause requires a WithEvents variable defined in the containing type or one of its base types.	C:\Documents and Settings\All Users\Documents\SBH-Webs\SBH-Webs\Form1.vb	48	116	SBH-Webs



I am almost finished with the errors, I just don't understand the whole with events thing. If anyone could help me fix these that would be awesome!!

And thanks for moving it, I'll probably get more help here

This post has been edited by sbh: 25 July 2008 - 05:30 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1