delphi 中一TXT文本中由10个空格隔开的数据把它们放到程序的一个数组中。怎么弄?
2个回答
展开全部
var
st, st1: TStringList;
ch: array[0..9] of Integer;
i: Integer;
begin
st := TStringList.Create();
st1 := TStringList.Create();
st.LoadFromFile('1.txt');
ExtractStrings([' '], ['.', '#'], PChar(st.Text), St1);
for i := 0 to 9 do
begin
ch[i] := StrToInt(st1[i]);
end;
st.Free;
st1.Free;
end;
st, st1: TStringList;
ch: array[0..9] of Integer;
i: Integer;
begin
st := TStringList.Create();
st1 := TStringList.Create();
st.LoadFromFile('1.txt');
ExtractStrings([' '], ['.', '#'], PChar(st.Text), St1);
for i := 0 to 9 do
begin
ch[i] := StrToInt(st1[i]);
end;
st.Free;
st1.Free;
end;
展开全部
Procedure TForm1.Button1Click(Sender: TObject);
Var
S: String;
alist: TStringList;
Begin
alist := TStringList.Create;
Try
alist.LoadFromFile('c:\ss.txt'); //加载以“”分段的文本。
alist.CommaText := alist.Text;
While alist.Count <> 0 Do
Begin
S := alist[0];
alist.Delete(0);
Application.MessageBox(PChar(S), 'MSG', 64);
End;
Finally
alist.Clear;
alist.Free;
End;
End;
Var
S: String;
alist: TStringList;
Begin
alist := TStringList.Create;
Try
alist.LoadFromFile('c:\ss.txt'); //加载以“”分段的文本。
alist.CommaText := alist.Text;
While alist.Count <> 0 Do
Begin
S := alist[0];
alist.Delete(0);
Application.MessageBox(PChar(S), 'MSG', 64);
End;
Finally
alist.Clear;
alist.Free;
End;
End;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询