Results 1 to 3 of 3

Thread: VBForums Code Tags

  1. #1

    Thread Starter
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,698

    VBForums Code Tags

    Introduction
    You may have been linked to this thread because you did not properly format your code in VBForums using the code BB tag. The purpose of this thread is to explain the purpose of code tags and to walk you through the process of using VBForums' code tags. At the end of this post you will find an animated GIF which shows you the process if you are a move visual learner.

    Purpose of Code Tags
    Code tags help preserve the whitespace in your code which makes it easier to read. In some cases, like python code, indentation is a necessity.

    Walkthrough
    Step 1) Type or paste your code into VBForums' text editor.
    Step 2) Select the entirety of your code.
    Step 3) Click the # button in the toolbar above the text editor.

    Your code in the text editor should look similar to this:
    [CODE]Console.WriteLine("Hello World!")[/CODE]

    Example Output
    Without Code Tags With Code Tags
    Option Strict On
    Public Module Module1
    Public Sub Main()
    Console.WriteLine("Hello world!")
    End Sub
    End Module
    Code:
    Option Strict On
    Public Module Module1
        Public Sub Main()
            Console.WriteLine("Hello world!")
        End Sub
    End Module

    Advanced
    You can elect to include syntax highlighting in your code by using the highlight tag. Follow steps 1 and 2 in the walkthrough but for step 3 click on the VB button in the toolbar above the text editor. This will bring up a dialog that prompts you to enter the option, this is where you would input the language. The following are a list of acceptable languages:

    • ABAP
    • Actionscript
    • Ada
    • Apache
    • AppleScript
    • x86 Assembler
    • ASP
    • BASH
    • BlitzBasic
    • BNF
    • AutoCAD/IntelliCAD Lisp
    • CFDG
    • ColdFusion
    • C for Macs
    • C
    • C++
    • C#
    • CSS
    • Delphi
    • Diff-output
    • DIV
    • DOS
    • dot
    • D
    • Eiffel
    • Fortran
    • FreeBasic
    • Genero
    • GML
    • Groovy
    • Haskell
    • HTML 4.01 strict
    • Unoidl
    • INI
    • Inno Script
    • Io
    • Java
    • Java
    • JavaScript
    • Generic Lisp
    • LUA
    • Motorola 68000 Assembler
    • Matlab M-file
    • mIRC Scripting
    • Microchip Assembler
    • MySQL
    • Nullsoft Scriptable Install System
    • Objective C
    • OCaml
    • OpenOffice.org Basic
    • Oracle 8
    • Pascal
    • Perl
    • Per
    • PHP
    • PHP
    • Oracle 9.2 PL/SQL
    • Python
    • QBasic/QuickBASIC
    • robots.txt
    • Ruby
    • SAS
    • Scheme
    • sdlBasic
    • Smalltalk
    • Smarty template
    • SQL
    • TCL/iTCL
    • thinBasic
    • T-SQL
    • VB.NET
    • Visual Basic
    • VHDL
    • Visual FoxPro
    • WinBatch
    • XML
    • Axapta/Dynamics Ax X++
    • ZiLOG Z80 Assembler


    Example Output of Highlight
    VB.NET Code:
    1. Private Sub Main()
    2.     Dim foo As String = "foo"
    3.     Console.WriteLine(foo)
    4.  
    5.     foo = "bar"
    6.     Console.WriteLine(bar)
    7. End Sub

    BNF Code:
    1. expression ::= number | expression, operator, expression | openParen, expression, closeParen
    2. number ::= [unaryOperator], digitExcludingZero, {digit}, [decimal, {digit}, digitExcludingZero]
    3. digit ::= (digitExcludingZero | '0'), {digit}
    4. digitExcludingZero ::= '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'
    5. operator ::= unaryOperator | '*' | '/' | '^'
    6. unaryOperator ::= '+' | '-'
    7. openParen ::= '('
    8. closeParen ::= ')'

    JavaScript Code:
    1. window.onload = function() {
    2.     document.getElementById('btnFoo').onclick = bntFoo_Click;
    3. }
    4.  
    5. function btnFoo_Click() {
    6.     alert('foo!');
    7. }

    Update
    Apparently after some updates, the advanced highlight tags no longer do syntax highlighting.

    Animated GIF

    Apparently after some updates, animated GIFs do not play. However, I have the image linked to the hosting service. If you click on the image you will be redirected to the animated image.
    Last edited by dday9; Apr 20th, 2021 at 10:58 AM. Reason: Added With and Without Example
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  2. #2
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,522

    Re: VBForums Code Tags

    Step 2 should be "Select" ... the code, not copy...

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,698

    Re: VBForums Code Tags

    Good catch, I changed the wording. I've also added some examples of using the [highlight][/highlight] tag.
    Last edited by dday9; Feb 17th, 2016 at 02:58 PM.
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width