Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
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.
 
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("<a href="http://google.com">http://google.com</a>") 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("<a href="http://google.com">http://google.com</a>") 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("<a href="http://www.google.co.in/search?hl=en&q=">http://www.google.co.in/search?hl=en&q=</a>" & ComboBox2.Text & "&btnG=Google+Search&meta=") End If If RadioButton2.Checked Then CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate("<a href="http://search.yahoo.com/search?p=">http://search.yahoo.com/search?p=</a>" & 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("<a href="http://www.youtube.com/results?search_query=">http://www.youtube.com/results?search_query=</a>" & 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 14-Nov-12 8:08am
Edited 14-Nov-12 8:17am
v2
Comments
Sergey Alexandrovich Kryukov at 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
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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:
<pre lang="C#">
// your code
</pre>
  Permalink  
Comments
dagronzzan at 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?
ProgramFOX at 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 at 14-Nov-12 13:37pm
   
does it work with visual basic 2008?
ProgramFOX at 14-Nov-12 13:38pm
   
I don't know. Try it.
I think it does work.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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:
<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

  Permalink  
v2

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

  Print Answers RSS
0 OriginalGriff 490
1 Sergey Alexandrovich Kryukov 405
2 Maciej Los 310
3 ProgramFOX 265
4 CHill60 200
0 OriginalGriff 490
1 Sergey Alexandrovich Kryukov 405
2 Maciej Los 285
3 ProgramFOX 265
4 Peter Leow 210


Advertise | Privacy | Mobile
Web04 | 2.8.150331.1 | Last Updated 14 Nov 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100