vault backup: 2025-07-14 10:52:43
This commit is contained in:
@ -491,13 +491,21 @@ begin
|
||||
end.
|
||||
```
|
||||
|
||||
## 转换了一下连接字符
|
||||
## 转换字符串数组的连接字符
|
||||
|
||||
当要设置自定义分隔符号,要将==**StringList.Delimiter := '-'; // 设置分隔符为分号**==往前面放
|
||||
当要设置自定义分隔符号,`StringList.Delimiter := '-';` 需要写在转化语句之前
|
||||
|
||||
<<<<<<< HEAD
|
||||
|
||||
uses MyClass,Variables,BaseUtil,CommonFunc,DataConst,CFFrm,CFSimplePropFrm,Forms,StdCtrls,Variants,SysUtils,Classes,Controls,Dialogs,
|
||||
CHostIntf,ProductClas,DocClas,LoginClas,VirtualTrees,CEntClas,PathClas;
|
||||
=======
|
||||
```delphi
|
||||
uses
|
||||
MyClass, Variables, BaseUtil, CommonFunc, DataConst, CFFrm, CFSimplePropFrm,
|
||||
Forms, StdCtrls, Variants, SysUtils, Classes, Controls, Dialogs,
|
||||
CHostIntf, ProductClas, DocClas, LoginClas, VirtualTrees, CEntClas, PathClas;
|
||||
>>>>>>> origin/main
|
||||
var
|
||||
StringList: TStringList;
|
||||
|
||||
@ -512,14 +520,51 @@ begin
|
||||
if fedtusr_lb.Text <> '' then
|
||||
StringList.Add(fedtusr_lb.Text);
|
||||
|
||||
==**StringList.Delimiter := '-'; // 设置分隔符为分号**==
|
||||
StringList.Delimiter := '-'; // 设置分隔符为分号
|
||||
// 转换为逗号分隔的字符串
|
||||
fedtFShtName.Text := StringList.DelimitedText; // 默认使用逗号作为分隔符
|
||||
|
||||
// 如果需要指定其他分隔符,可以设置Delimiter属性
|
||||
|
||||
// Result := StringList.DelimitedText;
|
||||
finally
|
||||
StringList.Free;
|
||||
end;
|
||||
end.
|
||||
end.
|
||||
```
|
||||
|
||||
### 拼接的另一种方式
|
||||
|
||||
由于采用 `StringList` 拼接会出现拼接的字符串中包含特殊字符时,默认给该字符串加上双引号的的情况,如图所示
|
||||
|
||||

|
||||
|
||||
那么对此可以采用另一种拼接方式,直接将字符串与字符串拼接起来,不再使用 `StringList` 记录再转化
|
||||
|
||||
```Delphi
|
||||
uses
|
||||
MyClass, Variables, BaseUtil, CommonFunc, DataConst, CFFrm, CFSimplePropFrm,
|
||||
Forms, StdCtrls, Variants, SysUtils, Classes, Controls, Dialogs,
|
||||
CHostIntf, ProductClas, DocClas, LoginClas, VirtualTrees, CEntClas, PathClas;
|
||||
var
|
||||
TempStr: string;
|
||||
begin
|
||||
TempStr := '';
|
||||
|
||||
if fedtusr_KHMC.Text <> '' then
|
||||
TempStr := fedtusr_KHMC.Text;
|
||||
|
||||
if fedtusr_khth.Text <> '' then
|
||||
begin
|
||||
if TempStr <> '' then
|
||||
TempStr := TempStr + '-'; // 添加分隔符
|
||||
TempStr := TempStr + fedtusr_khth.Text;
|
||||
end;
|
||||
|
||||
if fedtusr_lb.Text <> '' then
|
||||
begin
|
||||
if TempStr <> '' then
|
||||
TempStr := TempStr + '-'; // 添加分隔符
|
||||
TempStr := TempStr + fedtusr_lb.Text;
|
||||
end;
|
||||
|
||||
fedtFShtName.Text := TempStr; // 直接赋值
|
||||
end.
|
||||
```
|
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
Reference in New Issue
Block a user