They help me understand why, here are some examples
20 linesCode:Dim sString As String: Dim lTemp As Long: Dim iCont As Integer: Dim sText As String sString = Replace("First,Second,Third,Fourth,Fifth,Sixth,Seventh", ",", vbTab) For lTemp = 0 To 9999999 'sText = GetIt(sString, iCont) '20.5715377233699 miliseconds 'sText = GetIt1(sString, iCont) '39.5765626636905 miliseconds 'sText = GetIt2(sString, iCont) '23.1855129632397 miliseconds If iCont = 9 Then iCont = 0 Else iCont = iCont + 1 Next lTemp
8 linesCode:Public Function GetIt(ByVal vSource As String, vIndex As Integer, Optional vSep As String = vbTab) As String Dim oTexto As String Dim oTempo As Integer '2025-12-11 If vSource = "" Then oTexto = "" Else If InStr(vSource, vSep) > 0 Then oTexto = vSource + vSep Else Exit Function Do While InStr(oTexto, vSep) If oTempo = vIndex Then oTexto = Mid(oTexto, 1, InStr(oTexto, vSep) - 1) Exit Do ElseIf oTempo > vIndex Then oTexto = "" Exit Do End If oTexto = Mid(oTexto, InStr(oTexto, vSep) + Len(vSep)) oTempo = oTempo + 1 Loop If Len(oTexto) > 200 Then oTexto = Trim(oTexto) End If GetIt = oTexto End Function
17 linesCode:Public Function GetIt1(vSource As String, vIndex As Integer, Optional vSep As String = vbTab) As String Dim vStrings() As String '2026-07-03 If vSource <> "" Then If InStr(vSource, vSep) > 0 Then vStrings = Split(vSource, vSep) If vIndex <= UBound(vStrings) Then GetIt1 = vStrings(vIndex) Else Exit Function If Len(GetIt1) > 200 Then GetIt1 = Trim(GetIt1) End If End If End Function
Code:Public Function GetIt2(ByVal vSource As String, vIndex As Integer, Optional vSep As String = vbTab) As String Dim oTempo As Integer '2026-07-06 If vSource <> "" Then vSource = IIf(InStr(vSource, vSep) = 0, "", vSource + vSep) Do While InStr(vSource, vSep) If oTempo = vIndex Then vSource = Mid(vSource, 1, InStr(vSource, vSep) - 1) Exit Do ElseIf oTempo > vIndex Then vSource = "" Exit Do End If oTempo = oTempo + 1 vSource = Mid(vSource, InStr(vSource, vSep) + Len(vSep)) Loop If Len(vSource) > 200 Then vSource = Trim(vSource) End If GetIt2 = vSource End Function


Reply With Quote