Hello, I am building a web browser with tab control using VB 2010. I have everything working good so now I want to have it save the browser tabs when I shut down the browser and have them re-opened when I run the browser again like Chrome or Firefox would do. Thanks in advance for your replies.

I would have thought this is simply a case of adding code to your exit method (browser shutdown) to save the URLs of all open tabs to either a flat file or small database. On starting the browser read the file and open one tab per entry in the file.

I would personally use a File(possibly .txt or .ini) for I personally like having the option to locate my Default WebBrowsers ToolBar links, etc., and be able to view them just by browsing my.p.c..

I would personally use a File(possibly .txt or .ini) for I personally like having the option to locate my Default WebBrowsers ToolBar links, etc., and be able to view them just by browsing my.p.c..

Both responses are very helpful thanks...I am wondering would I just simply save the URL's to the file then tell my browser to load them on startup one by one? If so I haven't done much work with files in VB how would I start to go about that?

Basically, yes. When your browser starts up it will open the file, read the contents and parse the URLs. You can use basic file IO of .net to do that. Check stream readers and the file object online and you'll find plenty of simple tutorials to guide you.

See if this helps.
New Project, 1.TabControl(No Tabs), 1.Button(on.Form)

Imports System.IO
Public Class Form1
    Private myCoolWebBrowserSessionFile As String = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\myCoolWebBrowserSessionFile.txt"

    Private Sub Form1_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        With TabControl1
            If Not .TabPages.Count = 0 Then
                Dim sTemp As String = ""
                For Each myTab As TabPage In .TabPages
                    If Not sTemp = "" Then sTemp &= vbNewLine & wb(myTab).Url.AbsoluteUri Else sTemp = wb(myTab).Url.AbsoluteUri
                Next
                File.WriteAllText(myCoolWebBrowserSessionFile, sTemp)
            End If
        End With
    End Sub
    Private Function wb(ByVal selTab As TabPage) As WebBrowser
        Return CType(selTab.Controls.Item(0), WebBrowser)
    End Function

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        If File.Exists(myCoolWebBrowserSessionFile) Then
            Dim arTemp() As String = File.ReadAllLines(myCoolWebBrowserSessionFile)
            For Each itm As String In arTemp
                addTab(itm)
            Next
        End If
    End Sub
    Private Sub addTab(ByVal selUrl As String)
        Dim tab As New TabPage, wb As New WebBrowser With {.Dock = DockStyle.Fill}
        tab.Controls.Add(wb) : TabControl1.TabPages.Add(tab) : wb.Navigate(selUrl)
    End Sub

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        addTab("google.com")
    End Sub
End Class
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.