起步软件技术论坛-X3

 找回密码
 立即注册
搜索
查看: 150|回复: 2

【结】数组赋值报错

[复制链接]
发表于 2009-12-16 12:55:05 | 显示全部楼层 |阅读模式
var
  tmp1,rr :string;
  l,i,j,k:integer;
  n1,n2,n3:array of string;
  //const n1:array[0..9] of string=('零','壹','贰','叁','肆','伍','陆','柒','捌','玖');
  //const n2:array[0..3] of string=('','拾','佰','仟');
  //const n3:array[0..2] of string=('元','万','亿');
begin
  SetLength(n1,9);
  for i:=0 to length(n1)-1 do
  begin
      if i=0 then
      n1:='零';
      if i=1 then
      n1:='壹';
      if i=2 then
      n1:='贰';
      if i=3 then
      n1:='叁';
      if i=4 then
      n1:='肆';
      if i=5 then
      n1:='伍';
      if i=6 then
      n1:='陆';
      if i=7 then
      n1:='柒';
      if i=8 then
      n1:='捌';
      if i=9 then
      n1:='玖';
  end;
在 for i:=0 to length(n1)-1 do//报错Incompatible types: "String" and "String[]"
回复

使用道具 举报

发表于 2009-12-16 13:27:55 | 显示全部楼层
procedure TCT1.Button2Click(Sender: TObject);
var n1,n2 :array of string;
    i:integer;
begin
  SetLength(n1,9);
  for i :=0 to length(n1)-1 do
begin
      if i=0 then
      n1:='零';
      if i=1 then
      n1:='壹';
      if i=2 then
      n1:='贰';
      if i=3 then
      n1:='叁';
      if i=4 then
      n1:='肆';
      if i=5 then
      n1:='伍';
      if i=6 then
      n1:='陆';
      if i=7 then
      n1:='柒';
      if i=8 then
      n1:='捌';
      if i=9 then
      n1:='玖';
  end;

end;
我这里没有问题哦,换成 :
for i:=low(n1) to high(n1) do

看看呢?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2009-12-16 13:44:38 | 显示全部楼层
for i:=low(n1) to high(n1) do 这样可以了
结吧
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Justep Inc.

GMT+8, 2025-7-13 03:41 , Processed in 0.035630 second(s), 15 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表