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:
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
Click here to preview the VB Code Formatting Demo 2.
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!
|