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?
 
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
 
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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.