Delphi 用于将数字作为字符串添加到组合框文本中,增加0.1
我想在delphi 2010中,当文本增加0.1时,将数字从1添加到5添加到combobox,但会不断出现错误。我是一个自学成才的业余程序员,以前从未尝试过。这就是我所尝试的:Delphi 用于将数字作为字符串添加到组合框文本中,增加0.1,delphi,combobox,Delphi,Combobox,我想在delphi 2010中,当文本增加0.1时,将数字从1添加到5添加到combobox,但会不断出现错误。我是一个自学成才的业余程序员,以前从未尝试过。这就是我所尝试的: procedure TfrmWines.FillCombos; var c : TStringList; i : Double; begin c := TStringlist.Create; with c do begin sorted := True; duplicates
procedure TfrmWines.FillCombos;
var
c : TStringList;
i : Double;
begin
c := TStringlist.Create;
with c do
begin
sorted := True;
duplicates := dupIgnore;
end;
try
wdatamod.wines.first;
wdatamod.wines.DisableControls;
while not wdatamod.wines.eof do
begin
c.Add(wdatamod.wines.FieldByName('country').AsString);
wdatamod.wines.Next;
end;
finally
edCountryLst.Items := c;
wdatamod.wines.EnableControls;
c.Free;
end;
edRating.Items.Clear;
for i := 1 to 5 do
begin
edRating.Items.add(FloatToStr(0.1 +i));
end;
end;
我做错了什么?如果能帮我弄清楚,我将不胜感激。组合框字符串应为1、1.1、1.2等,直至5.0 多亏了@Remy Lebeau,这才是解决方案
procedure TfrmWines.FormActivate(Sender: TObject);
var
i : integer;
begin
edRating.Items.Clear;
for i := 10 to 50 do
begin
edRating.Items.add(FloatToStr(i /10));
end;
end;
再次感谢 这些错误是秘密吗?“或者你为什么不告诉我们它们是什么?”汤姆·布伦伯格。错误是“For loop control variable must have ordinal type”(For循环控制变量必须具有序号类型)。我已尝试将扩展和实数作为变量类型。事实上,您不能将
double
用作For循环变量。现在,停下来思考一下!这个问题是真的吗?您希望从10到50计数,并显示一个计数除以10的值。请这样做。