Advertisement
3_2004-2005 Miscellaneous #140307

Add User Initials to a block of selected text

If you have to add your username or initals tag to each change you make in code, this lets you select a block of text and add it to the end of each line.

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
'this event fires when the menu is clicked in the IDE
Private Sub MenuHandler_Click(ByVal CommandBarControl As Object, handled As Boolean, CancelDefault As Boolean)
  
  Dim MyPane As CodePane
  Dim lngStartLine As Long
  Dim lngEndLine As Long
  Dim lngStartCol As Long
  Dim lngEndCol As Long
  Dim strLine As String
  Dim tmpLine As String
  Dim i As Integer
  Dim LineLengths() As Integer
  Dim intLongestLine As Integer
  Dim intTotalLines As Integer
  Dim intLinecount As Integer
  Dim intDiff As Integer
    
  If strUser = "" Then
    strUser = "'"
    strUser = strUser & InputBox("Enter User Initials.", "Block Initials")
    strUser = strUser & " - " & Format(Now, "mm/dd/yy hh:mm")
  End If
  
  Set MyPane = VBInstance.ActiveCodePane
  MyPane.GetSelection lngStartLine, lngStartCol, lngEndLine, lngEndCol
  
  intTotalLines = lngEndLine - lngStartLine
  
  ReDim LineLengths(intTotalLines)
  intLinecount = 0
  
  For i = lngStartLine To lngEndLine - 1
    strLine = MyPane.CodeModule.Lines(i, 1)
    If intLongestLine < Len(strLine) Then
      LineLengths(intLinecount) = Len(strLine)
      intLongestLine = LineLengths(intLinecount)
    End If
    intLinecount = intLinecount + 1
  Next i
  
  
  For i = lngStartLine To lngEndLine - 1
    strLine = MyPane.CodeModule.Lines(i, 1)
    tmpLine = strLine
    If Trim(tmpLine) <> "" Then
      intDiff = intLongestLine - Len(strLine)
      MyPane.CodeModule.ReplaceLine i, strLine & Space(intDiff + 5) & strUser
    End If
  Next i
  
  
  
End Sub
Original Comments (3)
Recovered from Wayback Machine