Re: Extracting data from edit box



Hi Steve

A really cool and elegant trick (a friend showed me) is to replace
the seperator , in your case the ";", with chr(13) and read it into a
stringlist

procedure TForm1.Button1Click(Sender: TObject);
var tempstring : string;
sl:TStringList;

begin
tempstring := '"Co-Operative Bank Plc;@75;Burleigh Street;CAMBRIDGE;CB1
1DF';
sl:=TStringList.Create;

sl.Text:=StringReplace(tempstring,';',#13,[rfReplaceall]);
if sl.count > 0 then
memo1.Text := sl.Text;


sl.free;

end;

To get the last item in the list you can use :
lastitem := sl[sl.count-1];

How to delete the @ and the " depends on wether you want
to delete all @ and " or just the first one :
To delete all " you can use the copy procedure
while pos('"',tempstring)>0 do
tempstring:=copy(tempstring,pos('"',tempstring)+1,length(tempstring));


HTH
wolf




SteveW wrote:
> I have the following data in an edit box in the format :
>
> "Co-Operative Bank Plc;@75;Burleigh Street;CAMBRIDGE;CB1 1DF
>
> I need to put into a memo field as :
>
> Co-Operative Bank Plc
> 75 Burleigh Street
> CAMBRIDGE
> CB1 1DF
>
> ie strip out " from "Co-Operative Bank Plc
>
>
> ;@ from ;@75
> ; from Burleigh Street then add 75
>
> ; from CAMBRIDGE
>
> ; from CB1 1DF
>
> Also once in a memo how do I read the last item in the list.
>
>
> Cheers
>
> SteveW


.


Quantcast