VB / Visual Basic Code Formatting Demo 2


FormatCode Code Formatter is based on serveral powerful syntax parser engines so you can exactly control the appearance of your source code. Here is the code formatting demo of FormatCode VB Code Formatter to prove the ability of code formatting functions of FormatCode:

   '--- Before Code Formatting ---

      Global Const APPREMERR_USERCANCEL = 0  'user chose to cancel (no error)
    Global Const APPREMERR_NONFATAL = 1  'non-fatal error, user chose to abort
         Global Const APPREMERR_FATAL = 2 'fatal error
        Global Const APPREMERR_NONE = 3 'no error

     Sub CalcDiskSpace(ByVal strsection As String)
    Const GENERIC_WRITE = &H40000000
       Const GENERIC_READ = &H80000000
     Const FILE_ATTRIBUTE_NORMAL = &H80
       Const INVALID_HANDLE_VALUE = -1
           Const FILE_SHARE_READ = &H1
      Const FILE_SHARE_WRITE = &H2
              Const CREATE_NEW = 1
        Const CREATE_ALWAYS = 2
     Const OPEN_EXISTING = 3
       Const OPEN_ALWAYS = 4
           End Sub

      Type FILEINFO  ' Setup information file line format
     intDiskNum As Integer ' disk number
       fSplit As Integer       ' split flag
    strSrcName As String  ' name of source file
          strDestName As String ' name of destination file
      strDestDir As String  ' destination directory
        strRegister As String  ' registration info
     fShared As Boolean ' whether the file is shared or private
       fSystem As Boolean  ' whether the file is a system file
    varDate As Date  ' file date
         lFileSize As Long    ' file size
      sVerInfo As VERINFO      ' file version number
    strReserved As String   ' Reserved. Leave empty, or error.
        strProgramIconTitle As String    ' Caption for icon in program group
      strProgramIconCmdLine As String ' Command Line for icon in program group
            End Type

     Public Type SYSTEMTIME
      wMilliseconds As Integer
    wYear As Integer
        wMonth As Integer
       wDayOfWeek As Integer
     wDay As Integer
         wHour As Integer
        wMinute As Integer
           wSecond As Integer
      End Type

     Sub CalcDiskSpace(ByVal strsection As String)
       Static lDestFileSpace As Long
           Static fSplitFile As Integer

         Dim lThisFileSpace As Long
      Dim intIdx As Integer
        Dim intDrvIdx As Integer
     Dim sFile As FILEINFO
       Dim strDrive As String
    End Sub


   '--- After Code Formatting ---

   Global Const APPREMERR_USERCANCEL = 0  'user chose to cancel (no error)
   Global Const APPREMERR_NONFATAL = 1    'non-fatal error, user chose to abort
   Global Const APPREMERR_FATAL = 2       'fatal error
   Global Const APPREMERR_NONE = 3        'no error

   Sub CalcDiskSpace(ByVal strsection As String)
       Const GENERIC_WRITE = &H40000000
       Const GENERIC_READ = &H80000000
       Const FILE_ATTRIBUTE_NORMAL = &H80
       Const INVALID_HANDLE_VALUE = -1
       Const FILE_SHARE_READ = &H1
       Const FILE_SHARE_WRITE = &H2
       Const CREATE_NEW = 1
       Const CREATE_ALWAYS = 2
       Const OPEN_EXISTING = 3
       Const OPEN_ALWAYS = 4
   End Sub

   Type FILEINFO                        ' Setup information file line format
       intDiskNum As Integer            ' disk number
       fSplit As Integer                ' split flag
       strSrcName As String             ' name of source file
       strDestName As String            ' name of destination file
       strDestDir As String             ' destination directory
       strRegister As String            ' registration info
       fShared As Boolean               ' whether the file is shared or private
       fSystem As Boolean               ' whether the file is a system file
       varDate As Date                  ' file date
       lFileSize As Long                ' file size
       sVerInfo As VERINFO              ' file version number
       strReserved As String            ' Reserved. Leave empty, or error.
       strProgramIconTitle As String    ' Caption for icon in program group
       strProgramIconCmdLine As String  ' Command Line for icon in program group
   End Type

   Public Type SYSTEMTIME
       wMilliseconds As Integer
       wYear As Integer
       wMonth As Integer
       wDayOfWeek As Integer
       wDay As Integer
       wHour As Integer
       wMinute As Integer
       wSecond As Integer
   End Type

   Sub CalcDiskSpace(ByVal strsection As String)
       Static lDestFileSpace As Long
       Static fSplitFile As Integer

       Dim lThisFileSpace As Long
       Dim intIdx As Integer
       Dim intDrvIdx As Integer
       Dim sFile As FILEINFO
       Dim strDrive As String
   End Sub


Click here to preview the VB Code Formatting Demo 1.

With FormatCode VB Code Formatters, you can format and transform any foreign VB source code to meet your preferred coding style or any common code convention in several seconds!