in

vbCity Blogs

New (temp) place for vbCity Blogs

Serge B. Blog

September 2008 - Posts

  • How to format source code in vbCity forums and blogs

    To highlight code in your forum, blog and wiki posts wrap code into the folowing tags (example below is for VB.NET Code)

    [code language="VB.NET"][/code]

    Languages supported (in alphabetical order):

    • C
    • C++
    • C#
    • COBOL
    • Eiffel
    • Fortan
    • Haskell
    • HTML
    • Java
    • Javascript
    • Mercury
    • MSIL
    • Pascal
    • Perl
    • PHP
    • Python
    • Ruby
    • SQL
    • Visual Basic
    • VBScript
    • VB.NET
    • XML

    Visual Basic example:

    Public Sub CreateMyMultilineTextBox()
        ' Create an instance of a TextBox control.
        Dim textBox1 As New TextBox()
    
        ' Set the Multiline property to true.
        textBox1.Multiline = True
        ' Add vertical scroll bars to the TextBox control.
        textBox1.ScrollBars = ScrollBars.Vertical
        ' Allow the RETURN key in the TextBox control.
        textBox1.AcceptsReturn = True
        ' Allow the TAB key to be entered in the TextBox control.
        textBox1.AcceptsTab = True
        ' Set WordWrap to true to allow text to wrap to the next line.
        textBox1.WordWrap = True
        ' Set the default text of the control.
        textBox1.Text = "Welcome!" & Environment.NewLine & "Second Line"
    End Sub
    

    C# example:

    public void CreateMyMultilineTextBox()
     {
        // Create an instance of a TextBox control.
        TextBox textBox1 = new TextBox();
    
        // Set the Multiline property to true.
        textBox1.Multiline = true;
        // Add vertical scroll bars to the TextBox control.
        textBox1.ScrollBars = ScrollBars.Vertical;
        // Allow the RETURN key in the TextBox control.
        textBox1.AcceptsReturn = true;
        // Allow the TAB key to be entered in the TextBox control.
        textBox1.AcceptsTab = true;
        // Set WordWrap to true to allow text to wrap to the next line.
        textBox1.WordWrap = true;
        // Set the default text of the control.
        textBox1.Text = "Welcome!" + Environment.NewLine + "Second Line";
     }
    

     

    Posted Sep 29 2008, 08:11 PM by Serge B. with no comments
    Filed under: ,
  • How to wrap text inside <pre> tags in all browsers

    While looking for line-wrapping solution for syntax highlighted code blocks on the new vbCity community web site and had (once again) to search for the right <pre> tag CSS attributes that'd wrap code in all browsers. So, I ran at this great post that summarizes it all nicely and in one post:

    Wrapping Text Inside Pre Tags - http://www.longren.org/2006/09/27/wrapping-text-inside-pre-tags/

    Be sure to scroll down to the end of the article as Tyler keeps updating it with new attributes.

    Her is the latest style I use on this site that I found in Tyler's post:

    pre {
     overflow-x: auto; /* Use horizontal scroller if needed; for Firefox 2, not needed in Firefox 3 */
     white-space: pre-wrap; /* css-3 */
     white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */
     white-space: -pre-wrap; /* Opera 4-6 */
     white-space: -o-pre-wrap; /* Opera 7 */
     word-wrap: break-word; /* Internet Explorer 5.5+ */
    }
    

     

Copyright 1998-2009 vbCity.com LLC
Powered by Community Server (Non-Commercial Edition), by Telligent Systems