Solved

TEdit box question

Posted on 1998-10-17
7
152 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
  • 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 Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
This video discusses moving either the default database or any database to a new volume.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

708 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now