Attribute VB_Name = "udf_fromSet" '------------------------------------------------------------------------------- 'File : udf_fromSet.bas ' Copyright mpl by ERB software ' All rights reserved ' http://wiki.yaslaw.info/dokuwiki/doku.php/vba/functions/fromset 'Environment : VBA 2007 + 'Version : 1.0.0 'Name : fromSet 'Author : Stefan Erb (ERS) '------------------------------------------------------------------------------- Option Explicit '/** ' * Splittet ein Feld in Einzelteile und gibt dann den entsprechenden Wert zurück ' * Ist sehr gut geeignet um aus Queries zuzugreifen ' * ' * @example: "cdef" = fromSet(1, "ab,cdef,gh,j,klm") ' * ' * @param Int Index Wert der gewählt werden soll. Index beginnt mit 0 ' * @param String Text Text der gesplittet werden soll ' * @param String delemiter Trennzeichen um den Text zu splitten ' * @return String Extrahiert Teil ' */ Public Function fromSet(ByVal iIndex As Long, ByVal iSet As String, Optional ByVal iDelemiter As String = ",") As String Dim items() As String: items = Split(NZ(iSet), iDelemiter) If (LBound(items) <= iIndex And iIndex <= UBound(items)) Then fromSet = items(iIndex) End Function