|
Visual Basic/VB言語のソースコード整形例 |
|
|
|
|
|
SourceFormatX は優れた構文解析エンジンを元に作られています。ですのであらゆるスタイルで書かれたソースコードを美しく整形することができます。以下の例のようなめちゃくちゃなコードでさえも、整形することが可能です。
|
これは極端な例ですが。SourceFormatXに搭載されている強力な Visual Basic / 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::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: 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 _ (.FileVerPart2=sDestVer.FileVerPart2) AND _
(.FileVerPart3=sDestVer.FileVerPart3) And _
(.FileVerPart4=sDestVer.FileVerPart4) THEN goTo INVNewer
end with:INVNewer:IsNewerVer=True:End Function
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
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: 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 _ (.FileVerPart2 = sDestVer.FileVerPart2) And _
(.FileVerPart3 = sDestVer.FileVerPart3) And _
(.FileVerPart4 = sDestVer.FileVerPart4) Then GoTo INVNewer
End With
INVNewer:
IsNewerVer = True
End Function
再び手動でVisual Basic言語のソースコードを整形するために時を浪費しないで下さい! SourceFormatX体験版の無料ダウンロード!
|