Field Function

This function returns the n-th field from a given string divided by a delimiter.

Private Function Field(Regel As String, Veldnummer As Integer, Delimiter As String) As String
    Dim i As Integer
    Dim Veld As String
    Dim p As Integer
    Dim s As String

    s = Regel
    i = 1

    While i <= Veldnummer
        p = InStr(s, Delimiter)
        If p > 0 Then
            Veld = Left(s, p - 1)
            s = Right(s, Len(s) - p)
        Else
            Veld = s
            s = ""
        End If
        i = i + 1
    Wend
    Field = Veld
End Function