-
Feb 17th, 2016, 11:40 AM
#1
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:
Private Sub Main()
Dim foo As String = "foo"
Console.WriteLine(foo)
foo = "bar"
Console.WriteLine(bar)
End Sub
BNF Code:
expression ::= number | expression, operator, expression | openParen, expression, closeParen
number ::= [unaryOperator], digitExcludingZero, {digit}, [decimal, {digit}, digitExcludingZero]
digit ::= (digitExcludingZero | '0'), {digit}
digitExcludingZero ::= '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'
operator ::= unaryOperator | '*' | '/' | '^'
unaryOperator ::= '+' | '-'
openParen ::= '('
closeParen ::= ')'
JavaScript Code:
window.onload = function() {
document.getElementById('btnFoo').onclick = bntFoo_Click;
}
function btnFoo_Click() {
alert('foo!');
}
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
-
Feb 17th, 2016, 01:45 PM
#2
Re: VBForums Code Tags
Step 2 should be "Select" ... the code, not copy...
-tg
-
Feb 17th, 2016, 02:47 PM
#3
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.
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
|