简单的数组问题(30分)

  • 主题发起人 主题发起人 Heado
  • 开始时间 开始时间
H

Heado

Unregistered / Unconfirmed
GUEST, unregistred user!
请帮忙将以下VB语句翻译为Pascal语句.

Sub OutCompNames()

Dim oStrArray as StringArray
Dim i as Long
Set oStrArray=oSapDB.CompoundMaps.names
For i=0 To oStrArray.Count-1

MsgBox oStrArray(i)

Next

End Sub
 
注:
oSapDB为已经声明的对象.
 
>>Set oStrArray=oSapDB.CompoundMaps.names
是什么意思,不懂VB
 
oSapDB是一个对象,CompoundMaps是oSapD0中的一个集合对象,names是CompoundMaps的属性.
 
procedure OutCompNames;
var
oStrArray : TStringList;
i:integer;
begin
oStrArray := TStringList.Create;
oStrArray.AddStrings(oSapDB.CompoundMaps.names);
for i := 0 to oStrArray.Count-1 do
begin
showmessage(oStrArray.Strings);
end;
oStrArray.Free;
end;
 
procedure outcompnames;
var
ostrarray:array of String;
i:integer;
begin
setlength(ostrarray,osapdb.compoundmaps.count);
ostrarray:=Osapdb.compoundmaps.names;
for i:=1 to ostrarray.count do
showmessage(ostrarray)

end;
 
出现错误:
Project Project1.exe raised exception class EAccessViolation with
message 'Access violation at address 00405BCD in module
'PROJECT1.EXE'. Read of address FFFFFFFF'. Process stopped. Use
Step or Run to continue.

程序原码:
procedure TMainForm.OpenFileExecute(Sender: TObject);
var
Filename:String;
oStrArray : Array of String;
i,num:integer;
oCompoundMap:variant;
begin
oCompoundMap:=MainSpaDB.CompoundMaps;
num:=ocompoundMap.Count;
setlength(ostrarray,num);
ostrarray:=oCompoundMap.names;
for i:=1 to num do
showmessage(ostrarray);
end;
 
多人接受答案了。
 
后退
顶部