Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

TEdit box question

Posted on 1998-10-17
7
Medium Priority
?
166 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 150 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

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…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

688 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