|
Public Function ParseString(ByVal vsString As _
String, ByVal vsDelimiter As String, ByVal _ viNumber As Integer) Dim iFoundat As Integer Dim iFoundatold As Integer Dim iCurrentSection As Integer Dim sText As String If Len(vsString) > 0 And InStr(vsString, _ vsDelimiter) > 0 And viNumber > 0 Then iFoundat = 1 iFoundatold = 1 Do While InStr(iFoundatold + 1, vsString, _ vsDelimiter) > 0 iFoundatold = iFoundat iFoundat = InStr(iFoundat + 1, vsString, _ vsDelimiter) iCurrentSection = iCurrentSection + 1 Loop If viNumber > iCurrentSection Then Exit Function End If iFoundat = 1 iCurrentSection = 0 Do iFoundatold = iFoundat iFoundat = InStr(iFoundat + 1, vsString, _ vsDelimiter) If Trim(sText) = "" Then sText = Mid(vsString, 1, iFoundat - 1) iCurrentSection = iCurrentSection + 1 Else If iFoundat > 0 Then sText = Mid(vsString, iFoundatold + 1, _ (iFoundat - 1) - iFoundatold) Else sText = Mid(vsString, iFoundatold + 1) End If iCurrentSection = iCurrentSection + 1 End If If iCurrentSection = viNumber Then ParseString = sText Exit Do End If Loop End If ParseString = sText End Function |