memo1 + memo2

Hi, i have a bunch of names in my memo1 and the price and quintity in the other two memos, 2 and 3.

MEMO1 - MEMO2 - MEMO3
NAMES--PRICE------QUINT


if button1 click.. i need it to give output in a message saying the correct output for the matching name.
example,

if memo1.lines is 'fred' then begin show the price next to that and the Q.

To get the exact format, maybe we can count down the lines? so if fred in memo1 is 20th down... count 20 down each memo and give the result?



mem1 mem2 - memo3
calsc 5pounds jffmf
rtttry jgtjgjgj gjgkkh
rtrt gtgtgtkk6 gttgttg
fred test cool


so the result would be
FRED + TEST + COOL
Inter2001Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mlmccCommented:
A requirement like this only makes sense as a school assignment.
What code do you have for this thus far?

mlmcc
0
Inter2001Author Commented:
A school what? No, im 31 years old mate.

I dont have any code so far.
0
Ephraim WangoyaCommented:
Just use the index.

 
var
  I: Integer;
begin
  I := Memo1.Lines.IndexOf('Fred');
  ShowMessage(Memo1.Lines[I] +
                          Memo2.Lines[I] +
                          Memo3.Lines[I]);

Open in new window


Why don't you just use a TListView?
0
Become a CompTIA Certified Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

Emmanuel PASQUIERFreelance Project ManagerCommented:
yes, you'd better use a TListView (with ViewStyle=vsRepoort) instead of 3 memos.
You'll then have to define 3 columns for your control display, and the user will see a nice list instead of 3 lists that can be scrolled separately, thus creating a visually wrong match between the 3 lists lines.
To convert 3 lists into a listview, you can use the procedure below

LoadPurchasedItemsInListView(ListView1,mmoItems.Lines,mmoPrice.Lines,mmoQty.Lines);

then access your items + price + qty in the same TListItem. Only downside : it's harder to get the index of a line from the article name (you'll have to make your own IndexOf(Name) function)

procedure LoadPurchasedItemsInListView(lv:TListView;Items,Price,Qty:TStrings);
Var
 i:integer;
begin
 if (Items.Count<>Price.Count) Or (Items.Count<>Qty.Count)
  Then Raise Exception.Create('Items,Price & Qty lists count do not match ');
 lv.BeginUpdate;
 lv.Clear;
 for i:=0 to Items.Count-1 do
  With lv.Items.Add do
   begin
    Caption:=Items[i];
    SubItems.Add(Price[i]);
    SubItems.Add(Qty[i]);
   end;
 lv.EndUpdate;
end;

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Inter2001Author Commented:
Thanks for the replies, sorry it took me so long to get back here. I cant use listview guys as i have it all working with memos and it took alot of work to get the memos working with other parts of my project. I dont think i was clear with my original post.

I mean to say IF the word "super" exsists in memo1, show the word in a message, but make sure the memo2 and memo3 line is also displayed.

So if for example "super" is found in memo1, show in the message "jjj" and "lll"

super jjj lll  

Im trying to explain the best i can, hmmm. If super is at like 30 in memo1, show line 30 in memo2 and memo3 in the memo... I hope i explained this ok. Thanks for the help so far, i know that you both are among the best here, so i am in safe hands.
0
Inter2001Author Commented:
SORRY.

ewangoya: nailed it, thanks. However, can it be so that is "super" was found anywhere in the lin, for example "www.super.com" or "dhgfhSUPERjdrjf" it shows the line
0
mlmccCommented:
If you want SUPER surrounded by spaces then use " SUPER "

mlmcc
0
Inter2001Author Commented:
No, thats not what i mean, it could be in any format... "www.super.com", "hggSUPERMKK" , "GGsuper"
0
Inter2001Author Commented:
bump
0
huacatCommented:
like this:
var
  i : Integer;
begin
  for i := 0 to memo1.lines.count - 1 do
  begin
    if Pos('super', LowerCase(memo1.lines[i]) > 0 then
    begin
       if (i < memo2.lines.count) and (i < memo3.lines.count) then
          ShowMessage(memo1.lines[i] + memo2.lines[i] + memo3.lines[i])
       else
           raise Exception.Create('memo1 index can''t match memo2 or memo3');
       Break;
    end;
  end;
end;

Open in new window


Anyway, I'd like to re-factoring the function and UI, using fit-able control to show the right thing.
0
Geert GOracle dbaCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.