Java comment count (VBA material)

memorandum 2020/02.24 Single comment count

Option Explicit
Const Start_Row As Integer = 3
Const Start_Col As Integer = 2
Const Start_msg As String = "Start comment here"
Const End_msg As String = "End comment here"

Sub Del comment count()
Dim i As Integer
Dim MaxRow As Long
Dim DelCount As Long
Dim checkStr As String
Dim checkPoint As Boolean
checkPoint = False

'Get the last row of column B
MaxRow = Range("B65536").End(xlUp).Row
For i = 3 To MaxRow
    checkStr = Cells(i, Start_Col).Value
    checkStr = Trim(checkStr)

'In case of start message or second lap
    If checkStr = Start_msg Or checkPoint Then
        checkPoint = True
        checkStr = Left(checkStr, 1)
    
        ' /Comment judgment
        If checkStr = "/" Then
        ' *Reflect comments
        ElseIf checkStr = "*" Then
        'Blank line judgment
        ElseIf checkStr = "" Then
        Else
        'Set true for the second lap flag
        'Increment the count
            DelCount = DelCount + 1
        End If
    End If

    'For end messages
    If checkStr = End_msg Then
        'Set false to the second lap flag
        checkPoint = False
        'Subtract the count for start and end messages
        DelCount = DelCount - 2
    
    End If

Next i

MsgBox DelCount
End Sub

Recommended Posts

Java comment count (VBA material)
java Documentation Comment
Personal comment criteria [Java edition]