新手请教!下面的代码那里有问题??
unit Unit1;interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Button1: TButton;
ListBox1: TListBox;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
NumB: array[1..20] of integer;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
num1,i,j,k,setnum:integer;
sets1,sets:string;
begin
//NumB
sets:=Form1.Edit1.Text;
num1:=1;
if copy(sets,length(sets),1)<> ',' then sets:=edit1.Text+',';
while sets <> ' ' do
begin
setnum:=pos(',',sets); //,号在字串中的当前值
sets1:=copy(sets,1,setnum-1); // 把,号之后的值存入变量sets1
NumB[num1]:=strtoint(sets1); //把输出框中的值存入数组
sets:=copy(sets,setnum+1,length(sets)-setnum);//把已存入的数值之后的内容存入sets中,以便下次环
num1:=num1+1;
end;
for i:=1 to 19 do //冒泡法排序(选择法)
begin
k:=i; //小的数的记数器
// j:=i+1;
for j:=i+1 to 19 do
if NumB[j]<NumB[k] then k:=j;
if i<>k then
begin
// Numb[i]:=Numb[k]+Numb[i]; //交换比较的两个数
// Numb[k]:=Numb[i]-Numb[k];
// Numb[i]:=Numb[i]-Numb[k];
end;
end;
for i:=1 to 20 do
if numb[i]<>0 then listbox1.items.add(intTostr(numb[i]));
//向listbox中写数据,但不写0
end;
end.
========================
*编译没有问题,运行在edit1 框中输入数字后,却会弹出:
Project1.exe raised exception class econverterror with message''' is not a vilad integer value'. process stopped,use step or run to continue.
???
''不是整形??我想了半天都找不出是什么出了问题,
那位高手帮帮我!!!