|
-
Sep 8th, 2012, 11:56 AM
#1
Thread Starter
Member
First Application (Web Browser)
Yeah, there are a billion posts here about web browsers..
The first application in visual basic 2010 (Express) that i've created is a webbrowser with tabs, would be nice to have some feedback on it.
Screenshot:

Download link: http://uploading.com/files/get/a4dc6232/eBrowser.rar (Should work..)
Source Code: I commented it so it's easier to see what everything does.
Code:
Public Class Form1
'GoBack Button
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TabControl1.SelectedTab Is TabPage1 Then WebBrowser1.GoBack()
If TabControl1.SelectedTab Is TabPage2 Then WebBrowser2.GoBack()
If TabControl1.SelectedTab Is TabPage3 Then WebBrowser3.GoBack()
End Sub
'GoForward Button
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If TabControl1.SelectedTab Is TabPage1 Then WebBrowser1.GoForward()
If TabControl1.SelectedTab Is TabPage2 Then WebBrowser2.GoForward()
If TabControl1.SelectedTab Is TabPage3 Then WebBrowser3.GoForward()
End Sub
'Refresh Button
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If TabControl1.SelectedTab Is TabPage1 Then WebBrowser1.Refresh()
If TabControl1.SelectedTab Is TabPage2 Then WebBrowser2.Refresh()
If TabControl1.SelectedTab Is TabPage3 Then WebBrowser3.Refresh()
End Sub
'GoButton
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
If TabControl1.SelectedTab Is TabPage1 Then WebBrowser1.Navigate(RichTextBox1.Text)
If TabControl1.SelectedTab Is TabPage2 Then WebBrowser2.Navigate(RichTextBox1.Text)
If TabControl1.SelectedTab Is TabPage3 Then WebBrowser3.Navigate(RichTextBox1.Text)
End Sub
'KeyDown
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
'Url Bar Press Enter
If TabControl1.SelectedTab Is TabPage1 And RichTextBox1.Focused And e.KeyCode = Keys.Enter Then WebBrowser1.Navigate(RichTextBox1.Text)
If TabControl1.SelectedTab Is TabPage2 And RichTextBox1.Focused And e.KeyCode = Keys.Enter Then WebBrowser2.Navigate(RichTextBox1.Text)
If TabControl1.SelectedTab Is TabPage3 And RichTextBox1.Focused And e.KeyCode = Keys.Enter Then WebBrowser3.Navigate(RichTextBox1.Text)
'Normal Search Bar Press Enter
If TabControl1.SelectedTab Is TabPage1 And RichTextBox2.Focused And e.KeyCode = Keys.Enter Then WebBrowser1.Navigate("http://www.google.com/search?q=" & RichTextBox2.Text)
If TabControl1.SelectedTab Is TabPage2 And RichTextBox2.Focused And e.KeyCode = Keys.Enter Then WebBrowser2.Navigate("http://www.google.com/search?q=" & RichTextBox2.Text)
If TabControl1.SelectedTab Is TabPage3 And RichTextBox2.Focused And e.KeyCode = Keys.Enter Then WebBrowser3.Navigate("http://www.google.com/search?q=" & RichTextBox2.Text)
'Instant Search Bar Press Enter
End Sub
'Form1 Load
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TabControl1.TabPages.Remove(TabPage2)
TabControl1.TabPages.Remove(TabPage3)
TabControl1.TabPages.Remove(TabPage4)
End Sub
'Hide/Show TabControl1
Private Sub HideShowAllTabsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HideShowAllTabsToolStripMenuItem.Click
If TabControl1.Visible Then TabControl1.Hide() Else TabControl1.Show()
End Sub
'Exit Browser
Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
Close()
End Sub
'Reset Tabs
Private Sub ResetTabsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ResetTabsToolStripMenuItem.Click
WebBrowser1.Navigate("google.com")
WebBrowser2.Navigate("")
WebBrowser3.Navigate("")
End Sub
'Close SelectedTab
Private Sub CloseTab2ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CloseTab2ToolStripMenuItem.Click
If TabControl1.TabCount = 1 Or TabControl1.TabCount = 2 Or TabControl1.TabCount = 3 Then TabControl1.TabPages.Remove(TabControl1.SelectedTab)
If TabControl1.TabCount = 0 Then TextBox1.Show()
If TabControl1.TabCount = 1 Or TabControl1.TabCount = 2 Or TabControl1.TabCount = 3 Then TextBox1.Hide()
If TabControl1.TabPages.Contains(TabPage1) = False Then WebBrowser1.Navigate("")
If TabControl1.TabPages.Contains(TabPage2) = False Then WebBrowser2.Navigate("")
If TabControl1.TabPages.Contains(TabPage3) = False Then WebBrowser3.Navigate("")
End Sub
'Open Tab
Private Sub OpenTabToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenTabToolStripMenuItem.Click
If TabControl1.TabPages.Contains(TabPage1) And TabControl1.TabPages.Contains(TabPage2) And TabControl1.TabPages.Contains(TabPage3) = False Then
TabControl1.TabPages.Add(TabPage3)
TabControl1.SelectTab(TabPage3)
End If
If TabControl1.TabPages.Contains(TabPage1) And TabControl1.TabPages.Contains(TabPage2) = False And TabControl1.TabPages.Contains(TabPage3) = False Then
TabControl1.TabPages.Add(TabPage2)
TabControl1.SelectTab(TabPage2)
End If
If TabControl1.TabCount = 0 Then TabControl1.TabPages.Add(TabPage1)
If TabControl1.TabPages.Contains(TabPage1) And TabControl1.TabPages.Contains(TabPage3) And TabControl1.TabPages.Contains(TabPage2) = False Then
TabControl1.TabPages.Add(TabPage2)
TabControl1.SelectTab(TabPage2)
End If
If TabControl1.TabPages.Contains(TabPage1) = False And TabControl1.TabPages.Contains(TabPage2) Then
TabControl1.TabPages.Add(TabPage1)
End If
If TabControl1.TabPages.Contains(TabPage1) = False And TabControl1.TabPages.Contains(TabPage2) = False Then
TabControl1.TabPages.Add(TabPage1)
End If
If TabControl1.TabCount = 1 Or TabControl1.TabCount = 2 Or TabControl1.TabCount = 3 Then TextBox1.Hide()
End Sub
'Normal Search Button
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click, Button6.Click
If TabControl1.SelectedTab Is TabPage1 Then WebBrowser1.Navigate("http://www.google.com/search?q=" + RichTextBox2.Text)
If TabControl1.SelectedTab Is TabPage2 Then WebBrowser2.Navigate("http://www.google.com/search?q=" + RichTextBox2.Text)
If TabControl1.SelectedTab Is TabPage3 Then WebBrowser3.Navigate("http://www.google.com/search?q=" & RichTextBox2.Text)
End Sub
'Info MsgBox
Private Sub InfoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles InfoToolStripMenuItem.Click
MsgBox("eBrowser Version 1.4", , "Info")
End Sub
'Page Status, richtextbox1 show AbsoluteUri TAB1 and Tabpage.text = DocTitle
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
TabPage1.Text = WebBrowser1.DocumentTitle
If TabControl1.SelectedTab Is TabPage1 Then Label1.Text = WebBrowser1.StatusText
If TabControl1.SelectedTab Is TabPage1 Then RichTextBox1.Text = WebBrowser1.Url.AbsoluteUri
End Sub
'Page Status, richtextbox1 show AbsoluteUri TAB2 and Tabpage.text = DocTitle
Private Sub WebBrowser2_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser2.DocumentCompleted
TabPage2.Text = WebBrowser2.DocumentTitle
If TabControl1.SelectedTab Is TabPage2 Then Label1.Text = WebBrowser2.StatusText
If TabControl1.SelectedTab Is TabPage2 Then RichTextBox1.Text = WebBrowser2.Url.AbsoluteUri
End Sub
'Page Status, richtextbox1 show AbsoluteUri TAB3 and Tabpage.text = DocTitle
Private Sub WebBrowser3_Documentcompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser3.DocumentCompleted
TabPage3.Text = WebBrowser3.DocumentTitle
If TabControl1.SelectedTab Is TabPage3 Then Label1.Text = WebBrowser3.StatusText
If TabControl1.SelectedTab Is TabPage3 Then RichTextBox1.Text = WebBrowser3.Url.AbsoluteUri
End Sub
'Google Bookmark
Private Sub GoogleToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GoogleToolStripMenuItem.Click
If TabControl1.SelectedTab Is TabPage1 Then WebBrowser1.Navigate("google.com")
If TabControl1.SelectedTab Is TabPage2 Then WebBrowser2.Navigate("google.com")
If TabControl1.SelectedTab Is TabPage3 Then WebBrowser3.Navigate("google.com")
End Sub
'Youtube Bookmark
Private Sub YoutubeToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles YoutubeToolStripMenuItem.Click
If TabControl1.SelectedTab Is TabPage1 Then WebBrowser1.Navigate("youtube.com")
If TabControl1.SelectedTab Is TabPage2 Then WebBrowser2.Navigate("youtube.com")
If TabControl1.SelectedTab Is TabPage3 Then WebBrowser3.Navigate("youtube.com")
End Sub
'Show Settingstab
Private Sub SettingsToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SettingsToolStripMenuItem1.Click
TabControl1.TabPages.Add(TabPage4)
TabControl1.SelectTab(TabPage4)
End Sub
'BackColor ComboBox Apply
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
If ComboBox1.Text = "Silver" Then Me.BackColor = Color.Silver
If ComboBox1.Text = "Dark" Then Me.BackColor = Color.DimGray
If ComboBox1.Text = "Blue" Then Me.BackColor = Color.SteelBlue
If ComboBox1.Text = "Wood" Then Me.BackColor = Color.SaddleBrown
End Sub
'Close Settings Tab
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
TabControl1.TabPages.Remove(TabPage4)
End Sub
'Instant Search On/Off
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.Checked Then RichTextBox2.Hide() Else RichTextBox2.Show()
If CheckBox1.Checked Then Button5.Hide() Else Button5.Show()
If CheckBox1.Checked Then RichTextBox3.Show() Else RichTextBox3.Hide()
If CheckBox1.Checked Then Button9.Show() Else Button9.Hide()
End Sub
'Instant Search
Private Sub RichTextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RichTextBox3.TextChanged
If TabControl1.SelectedTab Is TabPage1 Then WebBrowser1.Navigate("http://www.google.com/search?q=" + RichTextBox3.Text)
If TabControl1.SelectedTab Is TabPage2 Then WebBrowser2.Navigate("http://www.google.com/search?q=" + RichTextBox3.Text)
If TabControl1.SelectedTab Is TabPage3 Then WebBrowser3.Navigate("http://www.google.com/search?q=" + RichTextBox3.Text)
End Sub
'Instant Search Button
Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
If TabControl1.SelectedTab Is TabPage1 Then WebBrowser1.Navigate("http://www.google.com/search?q=" + RichTextBox3.Text)
If TabControl1.SelectedTab Is TabPage2 Then WebBrowser2.Navigate("http://www.google.com/search?q=" + RichTextBox3.Text)
If TabControl1.SelectedTab Is TabPage3 Then WebBrowser3.Navigate("http://www.google.com/search?q=" + RichTextBox3.Text)
End Sub
'Fullscreen f11
Private Sub FullScreenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FullScreenToolStripMenuItem.Click
If Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None Then Me.FormBorderStyle = Windows.Forms.FormBorderStyle.Sizable Else Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
End Sub
End Class
Please give me some feedback on the code. Since this is my first application, the code is probably 5x as long as it could be and badly coded.
Thank you very much, sir.
-
Sep 8th, 2012, 11:59 AM
#2
Re: First Application (Web Browser)
Having those hard-coded If statements are not practical. What if the user doesn't have three tabs? You should be getting the SelectedTab first and then getting the appropriate WebBrowser from that TabPage. You might like to follow the CodeBank link in my signature and check out my Tabbed Web Browser thread to see how I handled that.
-
Sep 8th, 2012, 12:04 PM
#3
Thread Starter
Member
Re: First Application (Web Browser)
 Originally Posted by jmcilhinney
Having those hard-coded If statements are not practical. What if the user doesn't have three tabs? You should be getting the SelectedTab first and then getting the appropriate WebBrowser from that TabPage. You might like to follow the CodeBank link in my signature and check out my Tabbed Web Browser thread to see how I handled that.
Could you give me an example of how you would do it? It does work though, but you cant have more than 3 tabs.
-
Sep 8th, 2012, 12:05 PM
#4
Thread Starter
Member
Re: First Application (Web Browser)
 Originally Posted by jmcilhinney
Having those hard-coded If statements are not practical. What if the user doesn't have three tabs? You should be getting the SelectedTab first and then getting the appropriate WebBrowser from that TabPage. You might like to follow the CodeBank link in my signature and check out my Tabbed Web Browser thread to see how I handled that.
Could you give me an example of how you would do it? It does work though, but you cant have more than 3 tabs.
Edit: dunno why it double posted, these forums are pretty slow
-
Sep 8th, 2012, 12:07 PM
#5
Re: First Application (Web Browser)
Please read what I have already posted.
-
Sep 8th, 2012, 04:31 PM
#6
Thread Starter
Member
Re: First Application (Web Browser)
Sorry, was in a hurry.
 Originally Posted by jmcilhinney
Please read what I have already posted.
Can I have some more feedback please?
-
Sep 8th, 2012, 09:15 PM
#7
Addicted Member
Re: First Application (Web Browser)
I love the simple/clean GUI ....keep it up...very cool! :-)
p.s. i think what he's saying is....for an example of what he's talking about
follow the codebank link in his sig & look for how he handled the hard coded IF statements differently
as the example....
Last edited by jalexander; Sep 8th, 2012 at 09:20 PM.
dim jenn as geek = true
Learning ~ Visual Basic 2010 ~ in free time between college/work -
currently looking for a 'programming buddy' / 'coder friend' / and or 'mentor'. p.m. me if you
have ANY free time AT ALL I'm like 33% of a novice level ~ willing 2 listen/learn +
i am totally super motivated & promise to make an effffin amazing protege!!! #swag
| -_-_- -_-_- |
...W.T..F!?.....
||| Matter on the atomic/quantum level isn't solid or even matter at all. It can also exist in at least 2 places simultaneously (demonstrated in lab). It's position can only be established when it's actually observed. If we turn our back on it... it goes back to a wave form. History show's that every previous generation (since the beginning of time) got almost everything wrong. Then it might very well stand to reason that up is down & right can be wrong. Admit it.. our combined perception of reality is just that, we know absolutely nothing of actual reality & to think we do is simply subscribing to a "ignorance is bliss" mantra |||
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|