Function ValidateVBName(ByVal VBName As String, Optional ByVal acceptDots As _ Boolean = False) As Boolean Dim i As Long
If VBName Is Nothing OrElse VBName.Length = 0 OrElse VBName.Length > 255 _ Then Exit Function ElseIf VBName.IndexOf("..") >= 0 Then Exit Function End If
Dim pattern As String = "^[A-Z_][A-Za-z0-9_]*$" If acceptDots Then pattern = "^[A-Z_][A-Za-z0-9_.]*$" End If Dim re As New Text.RegularExpressions.Regex(pattern, _ Text.RegularExpressions.RegexOptions.IgnoreCase)
Return re.IsMatch(VBName)
End Function |