Option Explicit
'--------- 'esempio '--------- Private Sub Command1_Click() Dim a As String Dim n As Integer a = "aa|dd|ghtg|klm" For n = 1 To 4 MsgBox ExtractField(a, n, "|") Next End Sub Public Function ExtractField(ByVal strText As String, _ ByVal FieldPosition As Integer, _ ByVal CharDelimiter As String) As String Dim posStart, posStop, lenCar As Integer posStart = 1 Do While FieldPosition > 1 posStart = InStr(posStart, strText, CharDelimiter) + 1 FieldPosition = FieldPosition - 1 Loop posStop = InStr(posStart, strText, CharDelimiter) ExtractField = Mid(strText, posStart, _ IIf(posStop = 0, Len(strText) + 1, posStop - posStart)) End Function Inputs: stringa, posizione, Separatore Returns: Stringa Create un nuovo form ed inserite un Command button --> "Command1" |