Greetings,
i'm currently developing a web browser for my school project (i'm kinda new to advance visual basic)... it's 75% complete and the only problem i encountered is that when i enter items for the combo box it accepts duplicate .. for example i entered www.daniweb.com and re-entered it again, two www.daniweb.com will appear in the combo box's item and if i'll enter another url for example www.google.com it must be also added to combo box's item together with the www.daniweb.com and without any duplicates..how will i fix this? how can i remove the duplicate one?
here's the entire code of the system
Dim i As Integer
Dim int As Integer = 0
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
ComboBox1.Text = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Url.ToString
ToolStripLabel1.Text = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Url.AbsoluteUri
ComboBox1.Items.Add(CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Url.AbsoluteUri)
ToolStripProgressBar1.Value = ToolStripProgressBar1.Maximum
Timer1.Stop()
End Sub
Private Sub BtnSurf_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(ComboBox1.Text)
ComboBox1.Items.Remove(CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Url.AbsoluteUri)
End If
Next
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
ToolStripProgressBar1.Increment(1)
End Sub
Private Sub RemoveTabBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
If Not TabControl1.TabPages.Count = 1 Then
TabControl1.TabPages.RemoveAt(TabControl1.SelectedIndex)
TabControl1.SelectTab(TabControl1.TabPages.Count - 1)
int = int - 1
End If
End Sub
Private Sub AddTabBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Dim Browser As New WebBrowser
TabControl1.TabPages.Add("New Tab")
TabControl1.SelectTab(int)
Browser.Name = "Web Browser"
Browser.Dock = DockStyle.Fill
TabControl1.SelectedTab.Controls.Add(Browser)
AddHandler Browser.ProgressChanged, AddressOf Loading
AddHandler Browser.DocumentCompleted, AddressOf Done
int = int + 1
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoSearch()
End Sub
Private Sub goForwardBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoForward()
ToolStripProgressBar1.Value = ToolStripProgressBar1.Minimum
Timer1.Start()
End Sub
Private Sub goBackwardBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoBack()
ToolStripProgressBar1.Value = ToolStripProgressBar1.Minimum
Timer1.Start()
End Sub
Private Sub StopBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Stop()
End Sub
Private Sub Refresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Refresh()
ComboBox1.Text = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Url.ToString
ToolStripProgressBar1.Value = ToolStripProgressBar1.Minimum
Timer1.Start()
End Sub
Private Sub GoHomeBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoHome()
ToolStripProgressBar1.Value = ToolStripProgressBar1.Minimum
Timer1.Start()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim Browser As New WebBrowser
TabControl1.TabPages.Add("Untitled")
Browser.Name = "Web Browser"
Browser.Dock = DockStyle.Fill
TabControl1.SelectedTab.Controls.Add(Browser)
AddHandler Browser.ProgressChanged, AddressOf Loading
AddHandler Browser.DocumentCompleted, AddressOf Done
int = int + 1
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoSearch()
End Sub
Private Sub TextBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.Click
TextBox1.Clear()
TextBox1.Font = New System.Drawing.Font("", 8, Drawing.FontStyle.Regular)
End Sub
Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate("http://www.google.com/search?sclient=psy&hl=fil&site=&source=hp&q=" & TextBox1.Text)
ToolStripProgressBar1.Value = ToolStripProgressBar1.Minimum
Timer1.Start()
End Sub
Thanks! best regards,
cigoL:)