The time to use VC is not short, and recently noticed that the VC can also be customized. I wrote the following three, the effect is very good, greatly extended the service life of the keyboard. Introduce to everyone, I hope to help. 1. Adding a function Note Block VC Self-belonging macro Sample.dsm has an AddFunctionDescription macro to add an comment block to a function, but the format is simple, and it is very troublesome. So I only write a macro according to my annotation format, and only the data in the simple modification process can be easily changed into the annotation format you need (see the comments in the code, attached). The following is the current operation: / ***************************************** ******************************************** FUNCTION: Funname Purpose: parameters: type1 arg1 - type2 arg2arg2 - Type3 Arg3 - Return Type: Histype Comments: History: Date Author Comment 2005-4-18 Jason Created ********************************************** ****************************************************************************** / FUNTYPE Funname (Type1 Arg1, Type2 Arg2arg2, Type3 Arg3) Note that it is necessary to select. 2. Comment code, cancel code annotation, such as selected code rows (1), after running Comment, as shown (2), running Recomment, as shown (3), the same (1). (1) (2) (3) line1 // line1 line1 / * line2 * / // / & * line2 * & / / * line2 * / line3 // line3 line3 3. How to use 1) New files such as "MyMacros. DSM, copy code into the file, then put the file in the "C: / Program Files / Microsoft Visual Studio / Common / MSDEV98 / Macros" directory. 2) VC Menu -> Tools -> Customized, Select "Additional items and Macro files", select "MyMacors" 3) Set shortcuts. Select "Keyboard", select "Macros" in "Category", and then select the corresponding macro, set the shortcut 4) Set the menu button. Select "Command", select "Macros" in "Category", select the corresponding macro in "Commands", drag to the existing toolbar in the IDE interface, then select a suitable picture. 5) Option thereof in step 3, 4. 4. The code is where the function parseoarray is transplanted from the PFC, which is useful in character processing, I am often used in Excel.
'------------------------------------- ----------------------------- 'File Description: New Hong file' ------------- -------------------------------------------------- --------------- Sub addFundescription () 'Description: To select a function Add Note Block Dim Text, FunHeader, Funparms, DOCTAB, Author Dim Strfunname, Strfuntype Dim TMP (), StrParms DIM Funname, RetrunType, Parameters, History DoctAb = 4 'Table Sign, this program is used to align parameter list author = "jason"' my English name, please change into your big name 'DESC Control Comment block format, Modifying DESC can change the comment block into the format you need.
'After modification, pay attention to modify the upper boundary of the DESC, and the four parameters will be made to modify DIM DESC (15) DESC (0) = "/ ************** *********************************************************** ************ "DESC (1) =" "'Dark Dise DESC (2) =" Function: " VBTAB' This will add a function name DESC (3) =" "DESC ( 4) = "Purpose:" VBTAB DESC (5) = "" DESC (6) = "Parameters:" DESC (7) = VBTAB VBTAB 'The parameter list DESC (8) = "" "DESC (9) = "Return Type:" 'This will add function type DESC (10) = VBTAB VBTAB DESC (11) = "Comments:" VBTAB DESC (12) = "" DESC (13) = "History:" VBTAB "DATE" VBTAB VBTAB "Author" VBTAB VBTAB "Comment" DESC (14) = VBTAB VBTAB DESC (15) = "************** *********************************************************** ************* / "Funname = 2 'Planning Function" Row RETYPE = 9' Planning Function Type Row Parameters = 7 'Place of Place Parameters History = 14' Place HISTORY Row with activedocument.selection 'get function info text = trim (.text) if text = "" "" "" "," (") =" "", "(") = "" ",", "(") = "" " ParsetoArray GetStringbetween (Text, "," (")," ", TMP, TRUE IF Ubound (TM p) = 0 THEN EXIT SUB STRFUNNAME = TMP (Ubound (TMP)) for i = 0 to Ubound (TMP) - 1 strfuntype = strfuntype TMP (i) "Next ParsetoArray GetStringbetWeen (Text," (",") "),", ", strparms, true .startofline .newline .Lineup .text = dec (0) for line = 1 to Ubound .Newline .startofline if line =
FunName then .text = desc (line) strFunName elseif line = RetrunType then .text = desc (line) strFunType elseif line = Parameters then dim MaxLen, MaxTab for i = 0 to UBound (strParms) strParms (i) = Trim ( StrParms (I)) IF Maxlen
/ & * "," / * ".Replacetext" * & / "," * / ".startofline dsfirsttext .selectline pos = instr (.text," // ") if Pos> 0 damcancettext .delete 2 .CharRight dsExtend if .Text = "" then .Delete end if end if next End With end Sub '' function 'function ParseToArray (ByVal as_source, ByVal as_delimiter, as_array (), bPreventRepeat) Dim ll_DelLen, ll_Pos, ll_Count, ll_Start, ll_Length Dim ls_holder 'Check for NULL If IsNull (as_source) Or IsNull (as_delimiter) Then ParseToArray = Null End If' Check for at leat one entry If Trim (as_source) = "" Then ParseToArray = 0 End If 'Get the length of the delimeter ll_DelLen = Len (as_delimiter) ll_Pos = InStr (UCase (as_source), UCase (as_delimiter)) 'Only one entry was found If ll_Pos = 0 Then ReDim as_array (0) as_array (0) = as_source ParseToArray = 1 End If' More Than One Entry Was Found - Loop To Get All of Them LL_Count = -1 LL_Start = 1 Do WHILE LL_POS> 0 'SET CURRENT Entry LL_LENGTH = LL_POS - LL_START IF NOT BPREVENTREPEAT or LL_LENGTH> 0 T hen ls_holder = Mid (as_source, ll_Start, ll_Length) 'Update array and counter ll_Count = ll_Count 1 ReDim Preserve as_array (ll_Count) as_array (ll_Count) = ls_holder Else End If' Set the new starting position ll_Start = ll_Pos ll_DelLen ll_Pos = InStr (ll_Start, UCase (as_source), UCase (as_delimiter)) Loop 'Set last entry ls_holder = Mid (as_source, ll_Start, Len (as_source))' Update array and counter if necessary If Len (ls_holder)> 0 Then ll_Count = ll_Count 1 redim preserve as_Array (ll_count) as_ARRAY (LL_COUNT) =