Henry Olive 5 Posted November 4, 2022 Good Day, MyVar could be just '22-1' or could be '22-1, 22-2' or could be '22-1, 22-2, 22-3' or more i dont know but always there is a comma ( , ) between the str numbers I'll use these str numbers in a Sql like .... WHERE DOCNOS IN ('22-1', '22-2', ....) My Problem is 1= I don't know how many str numbers there are in MyVar 2= How to add QuotedStr into each document str number for sql where in Thank You Share this post Link to post
Rollo62 536 Posted November 4, 2022 (edited) How about something like TStringHelper.Split ? use System.SysUtils , System.Generics.Collections ; ... var LInput : String; LArray : TArray<String>; LElem : String; LStrQuo : String; begin LInput := '22-1, 22-2, 22-3'; LArray := LInput.Split( [ ',' ], TStringSplitOptions.ExcludeEmpty ); // Ignore empty elements for LElem in LArray do begin LStrQuo := LElem.Trim.QuotedString( '"' ); ... // Do something with the quoted in SQL end; end. Edited November 4, 2022 by Rollo62 3 Share this post Link to post
skyzoframe[hun] 4 Posted November 4, 2022 (edited) if ContainsText(LInput, ' ') then LInput := StringReplace(LInput,' ','',[rfReplaceAll]); Maybe you have to remove the SPACE character, before you put everything into array. Edited November 4, 2022 by skyzoframe[hun] Share this post Link to post
Henry Olive 5 Posted November 5, 2022 Thank you so much Rollo62, Skyzoframe Share this post Link to post