SourceFormatX

軟體簡介

主要功能

為什麼要使用

源碼美化演示

整合和插件

界面預覽

常見問題

升級歷史

所獲獎項

用戶評價

許可協議

CodeToHtml

Visual Basic原始碼美化效果演示

現在購買
下載試用

程式碼美化工具功能

SourceFormatX 使用強大的 Visual Basic 詞法解析引擎全面地分析您的原始碼並根據用戶自定義的VB原始碼風格重構和美化VB原始碼檔案,因此它能精細地根據不同的原始碼風格美化多種原始碼,甚至是下面這些極度混亂的原始碼:

C/C++ Java C# Delphi (Pascal)
PHP JSP ASP JavaScript
Visual Basic VB.NET VBScript HTML Components
80x86 ASM 8051 ASM CORBA IDL


這是一個非常極端的 Visual Basic (VB) 原始碼美化的範例,其目的是為了展示 SourceFormatX VB程式碼美化工具詞法解析引擎的威力。這份混亂到無法閱讀的 VB 原始碼檔案在1秒種內即可被 SourceFormatX 美化和縮排成整潔且可讀性強的美觀風格樣式。

  '----- 原始碼美化之前的VB語言原始碼 -----

  ATTRIBUTE VB_Name = "RegKeys":cONSt KEY_ALL_ACCESS=KEY_QUERY_VALUE+KEY_SET_VALUE+_
  	KEY_CREATE_SUB_KEY+KEY_ENUMERATE_SUB_KEYS+KEY_NOTIFY+_
   KEY_CREATE_LINK+READ_CONTROL:PUBLIC funCTION GetKeyValue(KeyRoot AS long,KeyName as sTRING, _
  SubKeyRef As String) As string:dim i AS LONG:DiM rc AS lONG::Rem Open RegKey Under KeyRoot
  rc=RegOpenKeyEx(KeyRoot,KeyName,0,KEY_ALL_ACCESS,hKey):if (rc <> ERROR_SUCCESS) ThEN GoTo GetKeyError
  tmpVal = String$(1024, 0):KeyValSize = 1024:rc=RegQueryValueEx(hKey, SubKeyRef, 0, _
  lKeyValType, tmpVal, KeyValSize):IF (rc <> ERROR_SUCCESS) then GOTo GetKeyError
      tmpVal=Left$(tmpVal,INSTR(tmpVal,ChR(0)) - 1):sELECT CASE lKeyValType:CAsE REG_SZ,REG_EXPAND_SZ
  sKeyVal=tmpVal:Case REG_DWORD:FOR i=leN(tmpVal) TO 1 Step -1
         sKeyVal=sKeyVal+Hex(Asc(Mid(tmpVal, i, 1))):NeXT:sKeyVal=Format$("&h"+sKeyVal):end SELECT
      GetKeyValue=sKeyVal:rc=RegCloseKey(hKey):EXIT FuNCTION
  					GetKeyError:	' Cleanup After An Error Has Occured
  GetKeyValue=vbNullString:rc=RegCloseKey(hKey)
  eND FunCTION:funCTION IsNewerVer(sSrcVer AS VERINFO,sDestVer as VERINFO) aS InTEGER
  IsNewerVer=False:WITH sSrcVer:IF (.FileVerPart1=sDestVer.FileVerPart1) and _ ' if statement
  						(.FileVerPart2=sDestVer.FileVerPart2) AND _
  	(.FileVerPart3=sDestVer.FileVerPart3) And _
   (.FileVerPart4=sDestVer.FileVerPart4) THEN goTo INVNewer
  end with:INVNewer:IsNewerVer=True:End Function

  '----- 原始碼美化之後的VB語言原始碼 -----

  ATTRIBUTE VB_Name = "RegKeys"
  Const KEY_ALL_ACCESS = KEY_QUERY_VALUE + KEY_SET_VALUE + _
                         KEY_CREATE_SUB_KEY + KEY_ENUMERATE_SUB_KEYS + _
                         KEY_NOTIFY + KEY_CREATE_LINK + READ_CONTROL

  '--------------------------------------------------------------------------

  Public Function GetKeyValue(KeyRoot As Long, KeyName As String, _
                              SubKeyRef As String) As String
      Dim i As Long
      Dim rc As Long
  
      Rem Open RegKey Under KeyRoot
      rc = RegOpenKeyEx(KeyRoot, KeyName, 0, KEY_ALL_ACCESS, hKey)
      If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError
      tmpVal = String$(1024, 0)
      KeyValSize = 1024
      rc = RegQueryValueEx(hKey, SubKeyRef, 0, _
           lKeyValType, tmpVal, KeyValSize)
      If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError
      tmpVal = Left$(tmpVal, InStr(tmpVal, Chr(0)) - 1)

      Select Case lKeyValType
          Case REG_SZ, REG_EXPAND_SZ
              sKeyVal = tmpVal
          Case REG_DWORD:
              Or i = Len(tmpVal) To 1 Step - 1
              sKeyVal = sKeyVal + Hex(Asc(Mid(tmpVal, i, 1)))
          Next

          sKeyVal = Format$("&h" + sKeyVal)
  End Select

  GetKeyValue = sKeyVal
  rc = RegCloseKey(hKey)
  Exit Function
  GetKeyError: ' Cleanup After An Error Has Occured
  GetKeyValue = vbNullString
  rc = RegCloseKey(hKey)
  End Function

  '--------------------------------------------------------------------------

  Function IsNewerVer(sSrcVer As VERINFO, sDestVer As VERINFO) As Integer
      IsNewerVer = False

      With sSrcVer

          If (.FileVerPart1 = sDestVer.FileVerPart1) And _ ' if statement
             (.FileVerPart2 = sDestVer.FileVerPart2) And _
             (.FileVerPart3 = sDestVer.FileVerPart3) And _
             (.FileVerPart4 = sDestVer.FileVerPart4) Then GoTo INVNewer
      End With

  INVNewer:
      IsNewerVer = True
  End Function

  不要再浪費寶貴的時間手動整理美化 Visual Basic / VB 語言原始碼了! 現在就下載SourceFormatX原始碼美化工具