Use the .Tag Property of the selectedTab when navigating to a site, to store the URL in. When switching between tabs, retrieve the .Tag of the selectedTab and display it in your TextBox. Hope this helps.
codeorder
Posting Virtuoso
1,915 posts since Aug 2010
Reputation Points: 255
Solved Threads: 384
Try this in a new project with a TabControl containing 2 TabPages.
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
With TabControl1
.TabPages(0).Tag = "hi"
.TabPages(1).Tag = "hello"
End With
End Sub
Private Sub TabControl1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TabControl1.SelectedIndexChanged
With TabControl1.SelectedTab
If Not .Tag Is Nothing Then MsgBox(.Tag)
End With
End Sub
End Class
All you have to do everytime you navigate a wb on a tabPage, set the .Tag of the .SelectedTab to the url you are navigating to.
Some webpages might change urls once your wb has finished loading the website, therefore it would be wise to set the .Tag in the wb_DocumentCompleted event as well.
codeorder
Posting Virtuoso
1,915 posts since Aug 2010
Reputation Points: 255
Solved Threads: 384
codeorder
Posting Virtuoso
1,915 posts since Aug 2010
Reputation Points: 255
Solved Threads: 384
Let's take baby steps.
1st. How are you navigating to a site for a selectedTab, or how are you getting the url into your TextBox from the selectedTab's WebBrowser? Post code.
codeorder
Posting Virtuoso
1,915 posts since Aug 2010
Reputation Points: 255
Solved Threads: 384
Go btn:
With TabControl1.SelectedTab
CType(.Controls.Item(0), WebBrowser).Navigate(TextBox1.Text)
.Text = CType(.Controls.Item(0), WebBrowser).DocumentTitle
.Tag = TextBox1.Text '// Add URL to .Tag of SelectedTab.
End With
Add Tab btn:
Private myHomepageURL As String = "http://oceanviewnewtab.webs.com"
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
With TabControl1
Dim browser As New WebBrowser With {.Name = "New_Tab", .Dock = DockStyle.Fill}
.TabPages.Add("New Tab" & i + 1)
.SelectTab(i)
.SelectedTab.Controls.Add(browser)
AddHandler browser.ProgressChanged, AddressOf bar_loading
AddHandler browser.DocumentCompleted, AddressOf done
CType(.SelectedTab.Controls.Item(0), WebBrowser).Navigate(myHomepageURL)
.SelectedTab.Tag = myHomepageURL '// Add URL to new tab's.Tag.
i += 1
.SelectedTab.Text = CType(.SelectedTab.Controls.Item(0), WebBrowser).DocumentTitle
End With
End Sub
TabControl:
Private Sub TabControl1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TabControl1.SelectedIndexChanged
With TabControl1.SelectedTab
If Not .Tag Is Nothing Then TextBox1.Text = .Tag
End With
End Sub
Let me know if this takes care of the issue or if we need to take some more baby steps.:D
codeorder
Posting Virtuoso
1,915 posts since Aug 2010
Reputation Points: 255
Solved Threads: 384