Function f_string_suchen(ia_trenner$, ia_such_str$, ia_ges_string$) As String '*********************************************************************************** 'Autor: Heiko Hommes 'Datum: 06.07.2006 'Beschr: hier wird ein string in einem mit trennzeichen getrenntem feld gesucht und ausgegeben 'Aufruf: In einer Abfrage f_string_suchen("[TRENNZEICHEN]";"[SUCH_STRING]";[gesamt_string]) ' f_string_suchen(";";"abcd","a;abcd;dew;dspr;") return "abcd" 'Rückgabe: such_string '************************************************************************************ On Error GoTo fehler 'Deklar. Variablen Dim feld(500) As String Dim pt As Integer Dim länge_feld As Integer Dim trenner As String Dim such_str As String Dim ges_string As String Dim pos_von As Integer Dim pos_bis As Integer such_str = ia_such_str trenner = ia_trenner ges_string = ia_ges_string pos_von = 1 pos_bis = 1 pt = 1 länge_feld = Len(ges_string) For pt = 1 To länge_feld Step 1 feld(pt) = "" Next pt länge_feld = Len(ges_string) For pt = 1 To länge_feld Step 1 feld(pt) = Mid(ges_string, pt, 1) Next pt For pt = 1 To länge_feld Step 1 If pt <= länge_feld Then If feld(pt) = trenner Then pos_von = pos_bis pos_bis = pt If pos_von < pos_bis Then If pos_von = 1 Then If such_str = Mid(ges_string, (pos_von), (pos_bis - pos_von)) Then f_string_suchen = Mid(ges_string, (pos_von), (pos_bis - pos_von)) Exit Function End If End If If such_str = Mid(ges_string, (pos_von + 1), (pos_bis - pos_von - 1)) Then f_string_suchen = Mid(ges_string, (pos_von + 1), (pos_bis - pos_von - 1)) Exit Function End If End If End If End If Next pt Exit Function fehler: msgbox (Err.Description) Exit Function End Function