Results 1 to 5 of 5

Thread: null reference exception was unhandled :|

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2009
    Posts
    2

    Angry null reference exception was unhandled :|

    Code:
    Public Class Form1
    
    
        Dim int As Integer = 0
        Dim CustomerTable As New DataTable
        Dim instance As New InvalidOperationException()
    
        Class TestClass
            Public field1 As Integer
            Dim field2 As Boolean
        End Class
    
    
    
    
        Private Sub Loading(ByVal sender As Object, ByVal e As Windows.Forms.WebBrowserProgressChangedEventArgs)
            ToolStripProgressBar1.Maximum = e.MaximumProgress
            ToolStripProgressBar1.Value = e.CurrentProgress
        End Sub
        Private Sub Done(ByVal sender As Object, ByVal e As Windows.Forms.WebBrowserDocumentCompletedEventArgs)
    
            TabControl1.SelectedTab.Text = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).DocumentTitle
            ToolStripComboBox1.Text = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Url.ToString
    
    
        End Sub
        Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
            CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoBack()
        End Sub
    
        Private Sub ToolStripButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton2.Click
            CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoForward()
        End Sub
    
        Private Sub ToolStripButton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton3.Click
            CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Refresh()
        End Sub
    
        Private Sub ToolStripButton4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton4.Click
            CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoHome()
    
        End Sub
    
        Private Sub ToolStripButton5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton5.Click
            CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(ToolStripComboBox1.Text)
        End Sub
        Private Sub ToolStripButton6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton6.Click
            CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoSearch()
        End Sub
    
        Private Sub PageProprietysToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PageProprietysToolStripMenuItem.Click
            CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).ShowPropertiesDialog()
    
        End Sub
        Private Sub ToolStripButton10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton10.Click
            Dim Browser As New WebBrowser
            TabControl1.TabPages.Add("New Page")
            TabControl1.SelectTab(int)
            Browser.Name = "FireWolf"
            Browser.Dock = DockStyle.Fill
            TabControl1.SelectedTab.Controls.Add(Browser)
            AddHandler Browser.ProgressChanged, AddressOf Loading
            AddHandler Browser.DocumentCompleted, AddressOf Done
    
            int = int + 1
        End Sub
    
    
    
    
    
    
    
        Private Sub PasteToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PasteToolStripButton.Click
            If Not TabControl1.TabPages.Count = 1 Then
            End If
            TabControl1.TabPages.RemoveAt(TabControl1.SelectedIndex)
            TabControl1.SelectTab(TabControl1.TabPages.Count - 1)
            int = int - 1
        End Sub
    
        Private Sub ToolStripButton9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton9.Click
            CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate("www.youtube.com")
        End Sub
    
        Private Sub ToolStripButton8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton8.Click
            CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate("www.yahoo.com")
        End Sub
    
        Private Sub ToolStripButton7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton7.Click
            CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate("www.google.com")
        End Sub
    
        Private Sub ToolStripComboBox1_keydown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ToolStripComboBox1.KeyDown
            If e.KeyCode = Keys.Enter Then
                ToolStripComboBox1.Items.Add(ToolStripComboBox1.Text)
                CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(ToolStripComboBox1.Text)
                Me.Text = (ToolStripComboBox1.Text)
    
            End If
        End Sub
        Private Sub ToolstripCombobox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripComboBox1.SelectedIndexChanged
            CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(ToolStripComboBox1.Text)
        End Sub
    
    End Class
    This is the code this exception occurs when i click on the home button of my webbrowser.
    Or i enter any site on the combobox.

  2. #2
    Frenzied Member
    Join Date
    Apr 2009
    Location
    CA, USA
    Posts
    1,516

    Re: null reference exception was unhandled :|

    This is not VBScript. Maybe VB.Net?

  3. #3
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: null reference exception was unhandled :|

    Do me and the rest of us a favor, please? Point out which line is the problem... you haven't given the buttons meaningfulnames, and I'm not going to even begin to try to figure out which of those buttons is your "home" button....

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: null reference exception was unhandled :|

    Based on Guuby's profile saying "Visual Basic 2008 express edition", I have moved this thread to our 'VB.Net' (VB2002 and later) forum.

  5. #5

    Thread Starter
    New Member
    Join Date
    Dec 2009
    Posts
    2

    Re: null reference exception was unhandled :|

    Ok first of all i am very sorry it is my first time here don't know exactly where to post i will try to give all the information demanded.
    I will make some screens to the problem.
    This exceptions always come if my browser navigates on a site or just press the button to go home...


    Code:
     CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoHome()
    This is the line that gives me the exception but this time it gives ArgumentOutOfRange Exception was unhandled...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width