• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Why does my code lose formatting while pasting in forum?

rumshar

Member
I was just wondering why the codes pasted by me(despite using code tags) lose formatting? Whereas codes pasted by others appears exactly as in VBE?
With Regards
Rudra
 
example:
Code:
Dim FSO, FileObj, FolderObj As Object
Dim WB As Workbook
Dim MyPath, Msg As String
Dim MyRow As Integer
Dim TDSAmt As Long
Dim TDSDetail, Response As String
 
Hi, rumshar!

I don't like using VB code tag because of this:
Code:
Option Explicit

Sub WTFAlignment()
' description
    ' constants
    Const ki1 = 1
    Const ks1 = "1"
    ' declarations
    '  something
    Dim I As Integer
    '  other things
    Dim A As String
    ' start
    A = ""
    ' process
    For I = 0 To ki1
        A = A & ks1
    Next I
    ' end
    MsgBox A
    Beep
End Sub

I prefer no code tag (in fact "someone" could someday update the dropdown list options at the dialog from "General code", PHP & HTML to something more suitable for these forums usage):
Code:
Sub WTFAlignment()
' description
    ' constants
    Const ki1 = 1
    Const ks1 = "1"
    ' declarations
    '  something
    Dim I As Integer
    '  other things
    Dim A As String
    ' start
    A = ""
    ' process
    For I = 0 To ki1
        A = A & ks1
    Next I
    ' end
    MsgBox A
    Beep
End Sub

The 2nd code reflects the real indenting of my code... With That Fooling Aligment... it's not a choice for me.

Regards!
 
@SirJB7
Thanks for differentiating these two types. I had not noticed that while 'Coloring' the code one has to compromise with the indent of it..
Just pasting your codes under different tag.(This is for experiment only)
PHP

PHP:
Sub WTFAli2gnment()
' description
    ' constants
    Const ki1 = 1
    Const ks1 = "1"
    ' declarations
    '  something
    Dim I As Integer
    '  other things
    Dim A As String
    ' start
    A = ""
    ' process
    For I = 0 To ki1
        A = A & ks1
    Next I
    ' end
    MsgBox A
    Beep
End Sub

General
Code:
Sub WTFAli2gnment()
' description
    ' constants
    Const ki1 = 1
    Const ks1 = "1"
    ' declarations
    '  something
    Dim I As Integer
    '  other things
    Dim A As String
    ' start
    A = ""
    ' process
    For I = 0 To ki1
        A = A & ks1
    Next I
    ' end
    MsgBox A
    Beep
End Sub

HTML
HTML:
Sub WTFAli2gnment()
' description
    ' constants
    Const ki1 = 1
    Const ks1 = "1"
    ' declarations
    '  something
    Dim I As Integer
    '  other things
    Dim A As String
    ' start
    A = ""
    ' process
    For I = 0 To ki1
        A = A & ks1
    Next I
    ' end
    MsgBox A
    Beep
End Sub
 
Back
Top