Login or Sign Up to become a member!
LessThanDot Sit Logo

LessThanDot

Community Wiki

Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.

LTD Social Sitings

Lessthandot twitter Lessthandot Linkedin Lessthandot friendfeed Lessthandot facebook Lessthandot rss

Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.

Navigation

Google Ads

Coding ToDo List

From Wiki

Revision as of 16:17, 20 June 2012 by Remou (Talk | contribs)
Jump to: navigation, search

A question was recently asked regarding a coding ToDo list similar to the one available in Visual Studio. Such a list is not available for MS Access and VBA, but it occurred to me that Search All Databases in Folder for Words in Code Modules could easily be adapted to provide a list of certain comments.

This code will list all comments included in the afind array.

  1. Sub ToDoList()
  2. Dim afind As Variant
  3. Dim sfound as String
  4. Dim mdl As Object
  5. Dim modtext As String, modarray As Variant
  6. Dim leline As Long
  7. Dim i, j, k  
  8.  
  9. afind = Split("HACK,TODO", ",")
  10.  
  11. For i = 1 To VBE.ActiveVBProject.VBComponents.Count
  12.     Set mdl = VBE.ActiveVBProject.VBComponents(i).CodeModule
  13.     leline = mdl.CountOfLines
  14.     If leline > 0 Then
  15.         modtext = mdl.Lines(1, leline)          
  16.         For j = 0 To UBound(afind)
  17.             If InStr(modtext, afind(j)) > 0 Then
  18.                 sfound = sfound & vbCrLf & "****" & afind(j) _
  19.                        & " found in " & mdl.Name
  20.                 modarray = Split(modtext, vbCrLf)
  21.                 For k = 0 To UBound(modarray)
  22.                     If InStr(modarray(k), afind(j)) > 0 Then
  23.                         sfound = sfound & vbCrLf & k
  24.                         sfound = sfound & "  " & modarray(k)
  25.                     End If
  26.                 Next
  27.             End If
  28.         Next
  29.     End If
  30. Next
  31.  
  32. MsgBox sfound
  33. End Sub

838 Rating: 2.3/5 (4 votes cast)