Need Help w/ WithEvent Errors Please

Need help with coding withevent variable into browser code asap please

  • (2 Pages)
  • +
  • 1
  • 2

27 Replies - 6163 Views - Last Post: 27 July 2008 - 04:49 PM Rate Topic: -----

#16 sbh  Icon User is offline

  • New D.I.C Head

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

Re: Need Help w/ WithEvent Errors Please

Posted 27 July 2008 - 02:22 PM

Sure do you want the code before or after all your guys edits/suggestions??

Did you mean the full code of the browser or the full code of the section we are working on??

This post has been edited by sbh: 27 July 2008 - 02:27 PM

Was This Post Helpful? 0
  • +
  • -

#17 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2264
  • View blog
  • Posts: 9,469
  • Joined: 29-May 08

Re: Need Help w/ WithEvent Errors Please

Posted 27 July 2008 - 02:29 PM

View Postsbh, on 27 Jul, 2008 - 10:22 PM, said:

Sure do you want the code before or after all your guys edits/suggestions??

If you could post pre-suggestion / solution. (full code as I think part of cause of the misunderstanding is elsewhere in the code)
Use [ code = vb] instead of [ code ] we'll get line numbers as well.

Then list the four errors.

This post has been edited by AdamSpeight2008: 27 July 2008 - 02:30 PM

Was This Post Helpful? 0
  • +
  • -

#18 sbh  Icon User is offline

  • New D.I.C Head

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

Re: Need Help w/ WithEvent Errors Please

Posted 27 July 2008 - 02:45 PM

K can do here it is let me know if it's not what you meant, if you need something else or if you want something different:

Pre:
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 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 printToolStripMenuItem.Click
        Dim printer As New PCPrint()
        printer.PrinterFont = New Font("Verdana", 10)
        printer.TextToPrint = TextBox1.Text
        printer.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 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


Solution:
Not quite sure how you guys wanted that put in, so if you could pasted that codes solution or something in the correct way it is supposed to look that would be great.

What I was was putting the line indrora gave (public static WithEvents....)
above the bit of code here:

(line indrora gave put here)
Private Sub NewWindowToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewWindowToolStripMenuItem.Click
		Dim f2 As New Form
		WebBrowser1.Navigate("http://www.sbhweb.co.nr")
		f2.Show()
	End Sub



But then it said something about the static not being vaild so I put it inside and all it would say was end of statement expected with the last part the line he gave me underlined.

This good?

Sorry Forgot 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 24 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 29 114 SBH-Webs

Error 3 Type 'PCPrint' is not defined. C:\Documents and Settings\All Users\Documents\SBH-Webs\SBH-Webs\Form1.vb 30 28 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 50 116 SBH-Webs

This post has been edited by sbh: 27 July 2008 - 02:55 PM

Was This Post Helpful? 0
  • +
  • -

#19 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2264
  • View blog
  • Posts: 9,469
  • Joined: 29-May 08

Re: Need Help w/ WithEvent Errors Please

Posted 27 July 2008 - 02:50 PM

sbh could you just edit your post the following line form
End Class[ / code =vb ]
to
end class[ / code]
Was This Post Helpful? 0
  • +
  • -

#20 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2264
  • View blog
  • Posts: 9,469
  • Joined: 29-May 08

Re: Need Help w/ WithEvent Errors Please

Posted 27 July 2008 - 03:05 PM

Fingers crossed this should work (Commented out cause of error3, printing out things different problem)
Public Class Form1
' Modifications 
' Moving them to here, makes them accessible to all the code in Form1
      Dim withEvents tabpage As New TabPage
      Dim withEvents Form1 As New WebBrowser
      Dim withEvents f2 As New Form
' End of mods

    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
        WebBrowser1.Navigate("http://www.sbhweb.co.nr")
        f2.Show()
    End Sub
' Commented out error3
'    Private Sub printToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles printToolStripMenuItem.Click
'  Dim printer As New PCPrint()
'        printer.PrinterFont = New Font("Verdana", 10)
'        printer.TextToPrint = TextBox1.Text
'        printer.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 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
        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


This post has been edited by AdamSpeight2008: 27 July 2008 - 03:08 PM

Was This Post Helpful? 0
  • +
  • -

#21 sbh  Icon User is offline

  • New D.I.C Head

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

Re: Need Help w/ WithEvent Errors Please

Posted 27 July 2008 - 03:13 PM

K two errors

Private Sub NewWindowToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles [u]NewWindowToolStripMenuItem[/u].Click
        WebBrowser1.Navigate("http://www.sbhweb.co.nr")
        f2.Show()
    End Sub


Same error

Private Sub SourceToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles [u]SourceToolStripMenuItem1[/u].Click
        Me.Show()
    End Sub


Same error
Was This Post Helpful? 0
  • +
  • -

#22 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2264
  • View blog
  • Posts: 9,469
  • Joined: 29-May 08

Re: Need Help w/ WithEvent Errors Please

Posted 27 July 2008 - 03:24 PM

View Postsbh, on 27 Jul, 2008 - 11:13 PM, said:

K two errors

Private Sub NewWindowToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles [u]NewWindowToolStripMenuItem[/u].Click
        WebBrowser1.Navigate("http://www.sbhweb.co.nr")
        f2.Show()
    End Sub


Same error

Private Sub SourceToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles [u]SourceToolStripMenuItem1[/u].Click
        Me.Show()
    End Sub


Same error


May seem a dumb question but do they exist on the form? SourceToolStripMenuItem1 & NewWindowToolStripMenuItem

This post has been edited by AdamSpeight2008: 27 July 2008 - 03:24 PM

Was This Post Helpful? 0
  • +
  • -

#23 sbh  Icon User is offline

  • New D.I.C Head

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

Re: Need Help w/ WithEvent Errors Please

Posted 27 July 2008 - 03:29 PM

Yest they do except for the <u>blabla bla</u> thing on them I was just trying to underline that part of them. The VB Express App put those there itself. I assume we just need the code for view page source and NewWindow to put inside.
Was This Post Helpful? 0
  • +
  • -

#24 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2264
  • View blog
  • Posts: 9,469
  • Joined: 29-May 08

Re: Need Help w/ WithEvent Errors Please

Posted 27 July 2008 - 03:41 PM

Rightclick on NewWindowToolStripMenuItem to bring up the menu.
Select "Go to Definition"
If the control exists on the form it should take you a line of code:
Don't alter it if does
Friend WithEvents NewWindowToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem


Do you?
Was This Post Helpful? 0
  • +
  • -

#25 sbh  Icon User is offline

  • New D.I.C Head

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

Re: Need Help w/ WithEvent Errors Please

Posted 27 July 2008 - 03:46 PM

Your right It doesn't but the source one does
Was This Post Helpful? 0
  • +
  • -

#26 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2264
  • View blog
  • Posts: 9,469
  • Joined: 29-May 08

Re: Need Help w/ WithEvent Errors Please

Posted 27 July 2008 - 03:58 PM

mmm, strange personnally I would Comment this code section out, then double click on the control and recode it again.
Private Sub SourceToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles [u]SourceToolStripMenuItem1[/u].Click
   Me.Show()
End Sub



See what happens. The See what the difference are.
Was This Post Helpful? 0
  • +
  • -

#27 sbh  Icon User is offline

  • New D.I.C Head

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

Re: Need Help w/ WithEvent Errors Please

Posted 27 July 2008 - 04:42 PM

K well I took out a new window thing, and the page source thing I did as you told me. How do I make it so that I can do a new window even if it's just an icon. Also how do I do a code for a print preview. And last If one the Private Sub..... Things doesn't have any code in it at all will it still do it's function or do you have to have some code to make it work??
I'll probably have to continue this tomorrow if that's okay but just some questions I need answered. Thanks so much for your help I'll get you a link or something so you can see the new and working prototype! Thanks again! :D :ph34r: :)
Was This Post Helpful? 0
  • +
  • -

#28 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2264
  • View blog
  • Posts: 9,469
  • Joined: 29-May 08

Re: Need Help w/ WithEvent Errors Please

Posted 27 July 2008 - 04:49 PM

View Postsbh, on 28 Jul, 2008 - 12:42 AM, said:

K well I took out a new window thing, and the page source thing I did as you told me. How do I make it so that I can do a new window even if it's just an icon. Also how do I do a code for a print preview. And last If one the Private Sub..... Things doesn't have any code in it at all will it still do it's function or do you have to have some code to make it work??
I'll probably have to continue this tomorrow if that's okay but just some questions I need answered. Thanks so much for your help I'll get you a link or something so you can see the new and working prototype! Thanks again! :D :ph34r: :)

cool
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2