Solved

TEdit box question

Posted on 1998-10-17
7
164 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
Independent Software Vendors: 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

Independent Software Vendors: 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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month9 days, 14 hours left to enroll

624 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