当前位置:主页>仓库管理软件> 列表

字符串处理问题 找进销存需求分析

库存管理软件版1楼: 00123485
00025896521
000085963215
就是去掉像上面字符串前面的0
变成
123458
25896521
85963215
因为这样的字串从串口ID卡中输入的,要求做一个函数来处理字符。

2楼: Int64toStr(Strtoint64(000123458))=123458 如进销存需求分析

3楼: 楼上的办法很好。也可以这样:
while Pos(''0'',str)=1 do
str ;= Copy(str,2,Length(str)-1);

4楼: unit Unit1;

interface

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

type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
function fieldstring(str:string): string;
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

function TForm1.fieldstring(str:string): string;
var
s:string;
begin
s:= IntToStr(StrToInt(str));
Result := s;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
st:string;
st1:string;
begin
st:=Edit1.Text;
st1:=fieldstring(st);
ShowMessage(st1);


end;

end.

5楼: StringReplace('''','''',[]); 你看帮助就知道了

6楼: StringReplace(''00001234'',''0'','''',[rfReplaceAll]);

库存管理软件版7楼: function TrimLeftZero(const S: string): string;
var
I, L: Integer;
begin
L := Length(S);
I := 1;
while (I <= L) and (S[I] = ''0'') do Inc(I);
Result := Copy(S, I, Maxint);
end;

8楼: 直接strtoint应该也可以吧>?

9楼: //先字符串转为整型
Strtoint64
Strtoint
//再将整型转为字符串
int64toStr
inttoStr
看你的是什么类型喽...

10楼: 多人接受答案了。