关于 vararraycreate 的求助 (50分)

  • 主题发起人 主题发起人 苦海无边
  • 开始时间 开始时间

苦海无边

Unregistered / Unconfirmed
GUEST, unregistred user!
....
deptidmax:integer;
.....

procedure TForm1.SpeedButton4Click(Sender: TObject);
var
i: integer;
tempid: integer;
begin
if (combobox6.Text = '') or (combobox7.Text = '') then
begin
showmessage('请选择考勤的年度和月份。');
if combobox6.Text = '' then combobox6.SetFocus
else combobox7.SetFocus;
end
else
begin
[red] d := vararraycreate([1, deptidmax], varstring);//这句话报错[/red]
for i := 1 to deptidmax do
begin
if checklistbox1.Checked then d := checklistbox1.Items.Strings;
tempid := tempid + 1;
end;
for i := 1 to tempid do
begin
if not query_post.Active then query_post.Open;
with query_post do
begin
close;
sql.Clear;
sql.Add('select type ,count(type) as num from sgin group by type');
sql.Add('where year(date)=:yy and month(date)=:mm');
Parameters.ParamByName('yy').Value := strtoint(combobox6.text);
parameters.parambyname('mm').Value := strtoint(combobox7.Text);
open;
end;
end;
d.free;
end;
end;
错误信息为error creating variant array.
不知道如何解决。
 
也不知道原因。
再from1.onshow里也有一句 那句就没问题
请教~!!
 
var
d :Variant;

d := vararraycreate([0, deptidmax-1], varstring);
这样试试。
 
procedure TForm1.Button1Click(Sender: TObject);
var
d:variant;
deptidmax:integer;
begin
deptidmax := 4;
d:=vararraycreate([0, deptidmax], varvariant);//
end;
可以通过!
 
d := vararraycreate([1, deptidmax], varstring);
d什么类型?
deptidmax是多少?
 
运行时出错还是编译时出错?
报告什么错误?
 
为什么不查一下帮助呢,

The element type of the array, given by the VarType parameter,
must be one of the TVarData type codes, and cannot include the
varArray or varByRef bits. [blue]The element type cannot be varString.
To create a Variant array of strings use the varOleStr type code[/blue].
If the element type is varVariant, the elements of the array are
themselves Variants and can in turn contain Variant arrays.
 
从0开始的呀
d := vararraycreate([0, deptidmax], varstring);
 
d:=vararraycreate([0, deptidmax], varvariant);//
偶最后是这么用的
继续研究我的出错原因,谢谢大家
 
ShowMessage(IntToStr(deptidmax));
d := vararraycreate([1, deptidmax], varstring);
就是先show一下deptidmax,看看它的值是多少?是不是你预期的?
 
多人接受答案了。
 

Similar threads

后退
顶部