Solved

TEdit box question

Posted on 1998-10-17
7
153 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

867 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

22 Experts available now in Live!

Get 1:1 Help Now