首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

delphi中怎么删除文本中一行 但不留空行

2012-03-12 
delphi中如何删除文本中一行 但不留空行unit Unit1interfaceusesWindows, Messages, SysUtils, Variants,

delphi中如何删除文本中一行 但不留空行
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, jpeg;

type
  TForm1 = class(TForm)
  Button1: TButton;
  Label1: TLabel;
  Button2: TButton;
  timer1: TTimer;
  Image1: TImage;
  Label2: TLabel;
  Label3: TLabel;
  Edit2: TEdit;
  Label4: TLabel;
  Label5: TLabel;
  procedure Timer1Timer(Sender: TObject);
  procedure Button1Click(Sender: TObject);
  procedure FormCreate(Sender: TObject);
  procedure Button2Click(Sender: TObject);
  procedure Edit2KeyPress(Sender: TObject; var Key: Char);


  private
  FList: TStrings;
  FIndex: Integer;

  { Private declarations }
  public
  { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  if FIndex >= FList.Count then FIndex := 0;
  LABEL5.Caption := FList.Strings[FIndex];
  Inc(FIndex);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
 FIndex := 0;
  Timer1.Interval := 20;
  if Length(edit2.Text)=5 then
  begin
  Timer1.Enabled := True;
  end
  else
  begin
  showmessage('请您输入正确编码!!!')
end
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  FList := TStringList.Create;
  FList.LoadFromFile('e:\slw\抽奖\抽奖测试\奖项.txt');
end;

procedure TForm1.Button2Click(Sender: TObject);
Var
  f: TextFile;
begin
Timer1.Enabled := False;
if (LABEL5.Caption='谢谢参与') then
  begin
  Application.MessageBox(pchar('感谢你的参与!!!!!!欢迎再次光临!!!!!'),
  pchar(Application.Title),MB_ICONINFORMATION + mb_Ok) ;
  end
  else
  Application.MessageBox(pchar('恭喜你抽中了'''+LABEL5.Caption+'''请联系工作人员领取!!'),
  pchar(Application.Title),MB_ICONINFORMATION + mb_Ok) ;
  AssignFile(f, 'e:\slw\抽奖\抽奖测试\中奖记录.txt');
  append(f);
  Writeln(f,edit2.text,LABEL5.Caption);
  CloseFile(f);
  LABEL5.Caption:='';
  edit2.Text:='';
end;


我想把TIMER1 停止的时候 把奖项中那个给删除 但是不留空行 把下面的那行提上来 
哪位大侠 帮帮忙 不胜感激!!!

[解决办法]
唉,delphi 最强的是面向对象啊,对象啊,对象啊。。。
难道现在学校老师都是用教学生们面向过程么?

你的 FList 就是一个很好的对象,在里面想删除哪行就删哪行,而且删除后不留空行,干嘛到最后却又来个面向过程的写法了?
看不懂啊看不懂。。。
[解决办法]

探讨

唉,delphi 最强的是面向对象啊,对象啊,对象啊。。。
难道现在学校老师都是用教学生们面向过程么?

你的 FList 就是一个很好的对象,在里面想删除哪行就删哪行,而且删除后不留空行,干嘛到最后却又来个面向过程的写法了?
看不懂啊看不懂。。。

热点排行