Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting Lines From Memo Or RichEdit 2

Status
Not open for further replies.

TBaz

Technical User
Jun 6, 2000
65
ES
I have a form with a RichEdit on it and I simply want to remove blank lines from any text file loaded into it.

I just can't figure out how to do this. There's no such thing as RichEdit1.Lines[N].Delete, and although the help files say that you need to use Strings[N].Delete, nothing I seem to do will work with the RichEdit.

Sorry if this is one of those often repeated questions - did a keyword search without luck.

Thanks...

Barrie
 
Hello Barrie

richedit.Lines.Delete(x);

will remove the line x from your rich edit.

Steve..
 
Let me get this straight.
You want to load a textfile and all the "completely" blank lines must be left out???

k, here's what i would do :

Procedure Proc;
var File : Textfile;
String : String;
Begin
Assignfile(File,'C:\MyTextFile.txt');
Reset(File);
While not File.Eof do
Begin
Readln(File,String);
If not String='' Then RichEdit1.Lines:=String;
End;
End;

dunno if it would work though (the if-statement) but it's worth a try.

grtz,
RobPouwelse E-mail: Rob@matas.nl (till Jan 10, from then on it's Deathwish@winning.com)
 
Thanks for the suggestions.

sggaunt hit the nail on the head! That must have been the only permutation I didn't try. Doh.

I had the parentheses AFTER the LINES instead of after the DELETE. Your example worked perfectly. The help files aren't exactly user-friendly on some subjects as often they link to the same piece of code - which often doesn't even mention the command I'm after help on!

RobPouwelse:

Thanks for your suggestion also. I didn't want to actually remove the empty lines until after the file was loaded, but your answer wasn't in vain - it gave me another idea for an additional option.

Many thanks to both of you.

Barrie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top