'  FF_VERIFY
'  确定字符串中的每个字符是否存在于另一个字符串中。
'  如果MainString中的每个字符出现在MatchPattern中，则返回零。
'  如果不是，则返回MainString中第一个不匹配字符的位置。
'  这个函数对于确定一个字符串是否只包含数字，对于xample非常有用。
'此功能区分大小写。
'如果nStart计算到字符串外的位置，或者nStart为零，
'那么该函数返回零。
'  Function FF_Verify( ByRef nStart        as Integer, _
'                      ByRef sMainString   as String, _
'                      ByRef sMatchPattern as String _
'                      ) as Integer
''
''  FF_VERIFY
''  Determine whether each character of a string is present in another string.
''
''  Returns zero if each character in MainString is present in MatchPattern. 
''  If not, it returns the position of the first non-matching character in MainString.
''  This function is very useful for determining if a string contains only numeric 
''  digits, for example.
''  This function is case-sensitive.
''  If nStart evaluates to a position outside of the string, or if nStart is zero, 
''  then the function returns zero.
''
Function FF_Verify( ByRef nStart        As Integer, _
                    ByRef sMainString   As String, _
                    ByRef sMatchPattern As String _
                    ) As Integer

   Dim nLenMain As Integer = Len(sMainString)
   Dim nPos     As Integer = -1   ' position of first non-match
   Dim i        As Integer
   Dim y        As Integer
   
   If (nStart <= 0) Or (nStart > Len(sMainString)) Then Return 0
   
   ' Get each character in sMainString and look for it in sMatchPattern
   ' Using string pointer indexing for speed.
   nStart = nStart - 1   ' convert to zero based
   For y = nStart To nLenMain - 1 
      i = InStr( sMatchPattern, Chr(sMainString[y]) )
      If i = 0 Then nPos = y: Exit For
   Next
    
   Function =  nPos + 1  ' convert back to one based
   
End Function

