bAllZero = False
                iC = Abs(i - 3)
                If (iC &gt; iMaxI) Then iMaxI = iC
                iC = Abs(j - 3)
                If (iC &gt; iMaxJ) Then iMaxJ = iC
            End If
            iIndex = iIndex + 1
        Next j
    Next i
    
    If (bAllZero) Then
        MsgBox "This filter would always cause the output image to be black. 
         Please enter a value.", vbInformation
        Exit Sub
    End If
    
    If (iMaxI &gt; iMaxJ) Then iMax = iMaxI Else iMax = iMaxJ
    