1、dyli向你讲解trim()函数说明
Trim函数最伟大的作用就是去掉头和尾的空格!!
使用前:
s=‘ a ’
使用后:
Trim(s)=‘a’
2、dyli的trim()函数案例设计证明
(1)、窗体文件设计
(2) trim()函数有史以来最经典代码片断
- var
- Form1: TForm1;
- tmptext :char='a';
- implementation
- {$R *.dfm}
- procedure TForm1.Button1Click(Sender: TObject);
- begin
- if Label1.Caption=tmptext then
- //这里不加trim()函数,则空格a空格 != a
-
- ShowMessage('the two char is equal')
- else
- ShowMessage('the two char is not equal');
- end;
- procedure TForm1.Button2Click(Sender: TObject);
- begin
- if trim(Label1.Caption)=tmptext then
- //这里加trim()函数,则a=a
- ShowMessage('the two char is equal')
- else
- ShowMessage('the two char is not equal');
- end;
3、trim()函数案例运行效果图