' Return the specific line in a string ' expN1 Line Public Function MLine(ByVal tnLine As Integer) As Boolean Dim lnLocation As Integer = 0 Dim loStringBuilderValueAdjusted As StringBuilder = New StringBuilder() ' If the line requested is greather than the number of lines If tnLine > nLine Then cLine = "" Return True End If ' If we are requesting the first ilne If tnLine = 1 Then ' See if we have more than one line If nLine > 1 Then cLine = Mid(oStringBuilder.ToString, 1, InStr(oStringBuilder.ToString, oApp.cCR) - 1) Else cLine = oStringBuilder.ToString End If Else ' Make sure we are able to find a carriage return lnLocation = oApp.At(oApp.cCR, oStringBuilder.ToString, tnLine - 1) If lnLocation > 0 Then loStringBuilderValueAdjusted.Append(Mid(oStringBuilder.ToString, _ oApp.At(oApp.cCR, oStringBuilder.ToString, tnLine - 1) + 2)) ' If this is not the last line lnLocation = InStr(loStringBuilderValueAdjusted.ToString, oApp.cCR) If lnLocation > 0 Then cLine = Mid(loStringBuilderValueAdjusted.ToString, 1, _ InStr(loStringBuilderValueAdjusted.ToString, oApp.cCR) - 1) Else cLine = loStringBuilderValueAdjusted.ToString End If Else cLine = oStringBuilder.ToString End If End If Return True End FunctionBasically, this code returns a specific line from a string. It was originally designed to match the MLine() function of VFP. But, now, under the .NET Framework 4.0, this runs extremely slow. The greater the number of lines in the string, the more the duration in time it takes to find the line.