Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
1.20/5 (4 votes)
See more:
i want to put the following code as a code for people in my article but i cant. can someone please help me? Either tell me how to do it or edit this and do it.

VB
Public Class Form1 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 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("New Page") 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).Navigate("http://google.com") End Sub Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click Dim Browser As New WebBrowser TabControl1.TabPages.Add("New Page") 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).Navigate("http://google.com") End Sub Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.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 Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).ShowPropertiesDialog() End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoBack() End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoForward() End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Refresh() End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoHome() End Sub Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Stop() End Sub Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(ComboBox1.Text) End Sub Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click If RadioButton1.Checked Then CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate("http://www.google.co.in/search?hl=en&q=" & ComboBox2.Text & "&btnG=Google+Search&meta=") End If If RadioButton2.Checked Then CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate("http://search.yahoo.com/search?p=" & ComboBox2.Text & "&fr=yfp-t-501&toggle=1&cop=mss&ei=UTF-8&fp_ip=IN&vc=") End If If RadioButton3.Checked Then CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate("http://www.youtube.com/results?search_query=" & ComboBox2.Text & "&search_type=&aq=-1&oq=") End If End Sub Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).ShowPrintDialog() End Sub Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).ShowPrintPreviewDialog() End Sub
End Class

thank you in advance,
dagronzzan
Posted
Updated 14-Nov-12 7:17am
v2
Comments
Sergey Alexandrovich Kryukov 14-Nov-12 14:04pm    
Not with the code you already put in this question -- the original formatting is lost. Your tag is correct -- "pre". As always with "pre", you need to preserve all of the original formatting: blank spaces, end line characters, tabs -- whatever it was.
--SA

To format code as a code block, and if you use the WYSIWYG editor, then choose "Formatted" in the left drop down, and set the language of your code block with the second drop down.

If you're not using the WYSIWYG editor, but the HTML editor,
then write your code into pre tags, and set the language of your code block with the lang attribute.
For example:
HTML
<pre lang="C#">
// your code
</pre>
 
Share this answer
 
Comments
dagronzzan 14-Nov-12 13:18pm    
I tried to copy and paste the code in but its all messed up. and i dont want to have to type everything in order again. any suggestions?
Thomas Daniels 14-Nov-12 13:23pm    
If you use Visual Studio, then paste your code into Visual Studio, press Ctrl+K and then Ctrl+D, then your code is formatted, try to copy and paste it again.
dagronzzan 14-Nov-12 13:37pm    
does it work with visual basic 2008?
Thomas Daniels 14-Nov-12 13:38pm    
I don't know. Try it.
I think it does work.
Yes, do it in HTML source mode, only accurately. WISIWYG is only good for relatively slow work. Use the tags as you did it in your question. Please see my comment to it.

Use the tags like this one:
HTML
<pre lang="vb">
... your code here ...
</pre>

You need to preserve all additional formatting. When you past, you can use the past option, depending on your content. If you pre-format everything, including HTML tags, you will need "paste as is".

—SA
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900