Solved

TEdit box question

Posted on 1998-10-17
7
163 Views
Last Modified: 2012-05-04
If i Writing in the edit box something like 'write bla'
then how can i get only the bla?

Daniel,
0
Comment
Question by:saar071697
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1343189
saar,

I assume what you want here is to extract everything after the first word. Of so then the following would do the trick:

var
  MyString : String;

.

MyString := '';
if pos(' ', MyEditBox.Text) > 0 then
  MyString := Copy(MyEditBox.Text, Pos(' ', MyEditBox.Text), length(MyEditBox.Text));


I hope this helps,

Raymond.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1343190
Here is a better way to do the same thing,,,,

var
  Str : String;
  nPos : Integer;
begin
   Str := '';
   nPos := pos('bla', Edit1.Text);
   if nPos > 0 then begin
    Str := Copy(Edit1.Text, nPos, Length('bla'));//where Length('bla') = 3
    Caption := Str;
  end;
end;

btw- It's actually the same approach but using a better method :->

Regards,
Viktor Ivanov
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1343191
Viktor: What if you don't know what 'bla' is?

saar: The pos call in my answer should be Pos(' ', MyEditBox.Text)+1 to avoid including the space (if you want the space don't go +1 :-)

Cheers,

Raymond.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Expert Comment

by:viktornet
ID: 1343192
Yeah that's true Raymond.

Saar: If you want to get a specific clause, phrase, use my way otherwise if you want to get the word after the space use Raymond's way. Here is something that will simplify things...

Function GetParsedItem(TheItemStr, ParseStr : String; ItemNum : Integer): String;
 Var
  I4 : Integer;
  S4 : String;
Begin
TheItemStr := TheItemStr + ParseStr;
  S4 := '';
 I4 := 0;
 While I4 <= ItemNum Do
  Begin
   S4 := Copy(TheItemStr, 1, Pos(ParseStr, TheItemStr) - 1);
   Delete(TheItemStr, 1, Pos(ParseStr, TheItemStr));
   Inc(I4);
  End;
  Result := S4;
End;

Example Call: If you want to get Bla in your example you should use this...

var
  Bla : string;
begin
  Bla := GetParsedItem(Edit1.Text, ' ', 1); //or was it 2 ?
end;

Hope this helps!

Regards,
Viktor Ivanov
0
 
LVL 2

Author Comment

by:saar071697
ID: 1343193
Raymond: i need to know the word "write" too becuase i need to something like this:
write bla = memo1.lines.add('*** Bla')
change blabla = edit2.text:= blabla

i hop u understand it

Daniel
0
 
LVL 12

Accepted Solution

by:
rwilson032697 earned 50 total points
ID: 1343194
OK, if you want to get the first word as well do this:

MyString := Copy(MyEditBox.Text, 1, Pos(' ', MyEditBox.Text) - 1);

Then rearrange your string as you require...

Cheers,

Raymond

(I could be missing the boat here - I'm sure you will let me know if I am...)
0
 
LVL 2

Author Comment

by:saar071697
ID: 1343195
Thanks!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question