' Equivalent of the AT() function in VFP ' expC1 Search for ' expC2 Search string ' expN1 Occurence ' expN2 Mode Public Function At(ByVal tcSearchFor As String, ByVal tcSearchIn As String, _ ByVal tnOccurence As Integer, ByVal tnMode As Integer) As Integer Dim lnCounter As Integer = 0 Dim lnLocation As Integer = 0 Dim lnOccured As Integer = 0 ' In this case we actually have to locate the occurence If tnMode = 1 Then lnLocation = 0 Else lnLocation = tcSearchIn.Length End If ' Loop through the string and get the position of the required occurence For lnCounter = 1 To tnOccurence If tnMode = 1 Then lnLocation = tcSearchIn.IndexOf(tcSearchFor, lnLocation) Else lnLocation = tcSearchIn.LastIndexOf(tcSearchFor, lnLocation) End If If lnLocation < 0 Then Exit For Else ' Increment the occured counter based on the current mode we are in lnOccured = lnOccured + 1 ' Check if this is the occurence we are looking for If lnOccured = tnOccurence Then Return lnLocation + 1 Else If tnMode = 1 Then lnLocation = lnLocation + 1 Else lnLocation = lnLocation - 1 End If End If End If Next Return 0 End FunctionThe reason I ask is that I thought if using a StringBuilder would be better here. This is considering that I have some string of up to 20k to be passed here. so, if tcSearchFor is 20k, could this be a factor?