< Public Function IsStartOf ( LookIn As String, LookFor As String, LookAtPosition As Integer, Optional SearchIf As Boolean = False, Optional UseFieldDelimiters As Boolean = False, Optional FieldDelimiters As String = "$" ) As Boolean (?)

Comments

'------------------------------------------------------------------------- 'Determine if given position in one string is the 'start of another string (field string) '-------------------------------------------------------------------------

Public Function IsStartOf ( LookIn As String, LookFor As String, LookAtPosition As Integer, Optional SearchIf As Boolean = False, Optional UseFieldDelimiters As Boolean = False, Optional FieldDelimiters As String = "$" ) As Boolean


    'Add text to front and back of field if necessary
    If UseFieldDelimiters Then
        LookFor = FieldDelimiters & LookFor & FieldDelimiters
    End If

    'Check there's space for the searchfield
    If Len(LookIn) - LookAtPosition < Len(LookFor) Then
        IsStartOf = False
        Exit Function
    End If

    'Check position is valid
    If LookAtPosition < 1 Or LookAtPosition > Len(LookIn) Then
        IsStartOf = False
        Exit Function
    End If

    'Check if word is at specified position
    If Mid(LookIn, LookAtPosition, Len(LookFor)) = LookFor Then
        IsStartOf = True
    Else
        IsStartOf = False
    End If
End Function


Copying, Return to index