L
liuchengr
Unregistered / Unconfirmed
GUEST, unregistred user!
我的Com中有一个Add方法(添加数据)及属性Value(返回当前记录中的Value值)
如果Add中的Value参数前缀为const时,出错。改为var后,正确,为什么?
结构体描述:
PParamItem = ^ParamItem;
ParamItem = record
Name: WideString;
DataType: emDataType;
ParamType: emDataType;
Precision: Integer;
Size: Integer;
Value: OleVariant;
end;
function TParams.Get_Value: OleVariant;
//属性Value的取值的实现函数
begin
IF not (FBof and FEof) then
Result := PParamItem(FList.Items[FIndex])^.Value
end;
function TParams.Add(const Name: WideString;
DataType: emDataType;
ParamType: emParamType;
Precision, Size: Integer;
var Value: OleVariant): Integer;
var
PItem: PParamItem;
begin
New(PItem);
IF FindByName(Name) then
Delete;
Result := FList.Add(PItem);
PItem^.Name := Name;
PItem^.DataType := DataType;
PItem^.ParamType := ParamType;
PItem^.Precision := Precision;
PItem^.Size := Size;
PItem^.Value := Value;
MoveTo(Result);
//移动到新添加的记录
end;
———test.asp(测试用的)———————————————————————
Set xx = Server.CreateObject("Project1.Params")
xx.Add "a",1,1,1,1,"af"
Response.Write xx.Value '这行出错
Set xx=Nothing
---------出错信息--------------------------
Microsoft VBScript 运行时错误 错误 '800a000d'
类型不匹配: 'Value'
/test.asp,行13
如果Add中的Value参数前缀为const时,出错。改为var后,正确,为什么?
结构体描述:
PParamItem = ^ParamItem;
ParamItem = record
Name: WideString;
DataType: emDataType;
ParamType: emDataType;
Precision: Integer;
Size: Integer;
Value: OleVariant;
end;
function TParams.Get_Value: OleVariant;
//属性Value的取值的实现函数
begin
IF not (FBof and FEof) then
Result := PParamItem(FList.Items[FIndex])^.Value
end;
function TParams.Add(const Name: WideString;
DataType: emDataType;
ParamType: emParamType;
Precision, Size: Integer;
var Value: OleVariant): Integer;
var
PItem: PParamItem;
begin
New(PItem);
IF FindByName(Name) then
Delete;
Result := FList.Add(PItem);
PItem^.Name := Name;
PItem^.DataType := DataType;
PItem^.ParamType := ParamType;
PItem^.Precision := Precision;
PItem^.Size := Size;
PItem^.Value := Value;
MoveTo(Result);
//移动到新添加的记录
end;
———test.asp(测试用的)———————————————————————
Set xx = Server.CreateObject("Project1.Params")
xx.Add "a",1,1,1,1,"af"
Response.Write xx.Value '这行出错
Set xx=Nothing
---------出错信息--------------------------
Microsoft VBScript 运行时错误 错误 '800a000d'
类型不匹配: 'Value'
/test.asp,行13