Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder Ludatha's Avatar
    Join Date
    Jan 2008
    Posts
    250
    Thanks
    51
    Thanked 5 Times in 5 Posts

    VB.net Tabbed browser + database

    Using Visual Basic 2008 Express Edition

    Hey guys, I have created a tabbed browser using a video tutorial, and it did work until I changed a few things around.

    When I type a URL in the box and click go I get this error:
    Code:
    Object reference not set to an instance of an object
    From this code:
    Code:
        Private Sub cmdGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdGo.Click
            CType(TabControl.SelectedTab.Controls.Item(0), WebBrowser).Navigate(WebURL.Text)
        End Sub
    also I have a search and I get the same error.
    Ive checked the names or everything and they all match.
    What do I do?


    Now I have loads of questions to ask, but I really want to know how to use a database with VB.net, I connected a database which has tables such as history etc.
    When 'DocumentCompleted' arrives how can I add the url and title to the database?

  • #2
    New Coder
    Join Date
    Oct 2008
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Now I have loads of questions to ask, but I really want to know how to use a database with VB.net, I connected a database which has tables such as history etc.
    When 'DocumentCompleted' arrives how can I add the url and title to the database?
    What kind of database do you want to use? and Can you provide the code of your tabbed browser ?

  • #3
    Regular Coder Ludatha's Avatar
    Join Date
    Jan 2008
    Posts
    250
    Thanks
    51
    Thanked 5 Times in 5 Posts
    Quote Originally Posted by niceguy78 View Post
    What kind of database do you want to use? and Can you provide the code of your tabbed browser ?
    I want to use a Microsoft Access 2007 database.
    Ive already conected it, I just dont know how to put and pull data from it.

    My whole code is:
    Code:
    Public Class Main
    
        Public BackCount As Integer
        Public ForwardCount As Integer
    
        Public SearchErrCount As Integer
        Public SearchProvider As String
    
        Dim i As Integer = 0
    
        Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
            Me.Close()
        End Sub
    
        Private Sub btnHome_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
            CType(TabControl.SelectedTab.Controls.Item(0), WebBrowser).GoHome()
        End Sub
        Private Sub WebBrowser_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs)
            Main.ActiveForm.Text = CType(TabControl.SelectedTab.Controls.Item(0), WebBrowser).DocumentTitle + " - LudathaMicro"
            WebURL.Text = CType(TabControl.SelectedTab.Controls.Item(0), WebBrowser).Url.AbsoluteUri
            If BackCount > 0 Then
                cmdBack.Enabled = True
            Else
                cmdBack.Enabled = False
            End If
    
            If ForwardCount > 0 Then
                cmdForward.Enabled = True
            Else
                cmdForward.Enabled = False
            End If
    
        End Sub
    
        Private Sub cmdGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdGo.Click
            CType(TabControl.SelectedTab.Controls.Item(0), WebBrowser).Navigate(WebURL.Text)
        End Sub
    
        Private Sub cmdStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdStop.Click
            CType(TabControl.SelectedTab.Controls.Item(0), WebBrowser).Stop()
        End Sub
    
        Private Sub cmdReload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdReload.Click
            CType(TabControl.SelectedTab.Controls.Item(0), WebBrowser).Refresh()
        End Sub
    
        Private Sub cmdBack_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdBack.Click
            CType(TabControl.SelectedTab.Controls.Item(0), WebBrowser).GoBack()
            ForwardCount = Int(1)
            BackCount = Int(-1)
        End Sub
    
        Private Sub cmdForward_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdForward.Click
            CType(TabControl.SelectedTab.Controls.Item(0), WebBrowser).GoForward()
            BackCount = Int(1)
            ForwardCount = Int(-1)
        End Sub
    
        Private Sub WebBrowser_LocationChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
            BackCount = Int(1)
        End Sub
    
        Private Sub LoginToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LoginToolStripMenuItem.Click
            CType(TabControl.SelectedTab.Controls.Item(0), WebBrowser).Navigate("http://www.ludatha.com")
        End Sub
    
        Private Sub txtSearcher_DropDownItemClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles txtSearcher.DropDownItemClicked
    
        End Sub
    
        Private Sub GoogleToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GoogleToolStripMenuItem.Click
            txtSearcher.Text = GoogleToolStripMenuItem.Text
            txtSearcher.Image = GoogleToolStripMenuItem.Image
        End Sub
    
        Private Sub YahooToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles YahooToolStripMenuItem.Click
            txtSearcher.Text = YahooToolStripMenuItem.Text
            txtSearcher.Image = YahooToolStripMenuItem.Image
        End Sub
    
        Private Sub cmdSearch_Click() Handles cmdSearch.Click
            SearchErrCount = 0
    
            If SearchErrCount = 0 Then
                If txtSearcher.Text = "Google" Then
                    SearchProvider = "http://www.google.com/search?q="
                ElseIf txtSearcher.Text = "Yahoo" Then
                    SearchProvider = "http://search.yahoo.com/search?p="
    
                Else
                    SearchProvider = "http://www.google.com/search?q="
                End If
                CType(TabControl.SelectedTab.Controls.Item(0), WebBrowser).Navigate(SearchProvider + txtSearch.Text)
            End If
        End Sub
    
        Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click
            About.Show()
        End Sub
    
        Private Sub OptionsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OptionsToolStripMenuItem.Click
            Options.Show()
        End Sub
    
        Private Sub BookmarkThisPageToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BookmarkThisPageToolStripMenuItem.Click
    
        End Sub
    
        Private Sub BookmarksBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
            Me.Validate()
            Me.BookmarksBindingSource.EndEdit()
            Me.TableAdapterManager.UpdateAll(Me.LudathaMicro_DataDataSet)
    
        End Sub
    
        Private Sub Main_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            'TODO: This line of code loads data into the 'LudathaMicro_DataDataSet.Bookmarks' table. You can move, or remove it, as needed.
            Me.BookmarksTableAdapter.Fill(Me.LudathaMicro_DataDataSet.Bookmarks)
    
            Dim browse As New WebBrowser
            TabControl.TabPages.Add(i, "New Tab")
            TabControl.SelectTab(i)
            browse.Name = "b1"
            browse.Dock = DockStyle.Fill
            TabControl.SelectedTab.Controls.Add(browse)
            i = i + 1
    
        End Sub
        Private Sub cmdNewTabToolBar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdNewTabToolBar.Click
            Dim browse As New WebBrowser
            browse.Name = "b1"
            browse.Dock = DockStyle.Fill
            AddHandler browse.DocumentCompleted, AddressOf browse_done
            TabControl.TabPages.Add(i, "New Tab")
            TabControl.SelectTab(i)
            TabControl.SelectedTab.Controls.Add(browse)
            i = i + 1
        End Sub
    
        Private Sub browse_done(ByVal sender As Object, ByVal e As Windows.Forms.WebBrowserDocumentCompletedEventArgs)
            TabControl.SelectedTab.Text = CType(TabControl.SelectedTab.Controls.Item(0), WebBrowser).DocumentTitle
        End Sub
    End Class
    I made a simple code to enable the forward and back buttons, but it kinda failed, so thats another reason for me to use the database xD

  • #4
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Quote Originally Posted by Ludatha View Post

    When I type a URL in the box and click go I get this error:
    Code:
    Object reference not set to an instance of an object
    From this code:
    Code:
        Private Sub cmdGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdGo.Click
            CType(TabControl.SelectedTab.Controls.Item(0), WebBrowser).Navigate(WebURL.Text)
        End Sub
    That error means that one of the objects you are trying to use is null. Such as TabControl.SelectedTab.
    OracleGuy

  • Users who have thanked oracleguy for this post:

    Ludatha (10-06-2008)

  • #5
    New Coder
    Join Date
    Oct 2008
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I want to use a Microsoft Access 2007 database.
    Ive already conected it, I just dont know how to put and pull data from it.
    I do not see connection line in your program, what kind of connection you use, I mean, do you use ODBC connection or SQL connection.

  • #6
    Regular Coder Ludatha's Avatar
    Join Date
    Jan 2008
    Posts
    250
    Thanks
    51
    Thanked 5 Times in 5 Posts
    Hey sorry for the late reply :O
    I did actually remove the connection line, because I though I might have been the cause of the problems.
    I am using SQL to connect to the database.


  •  

    Tags for this Thread

    Posting Permissions

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