Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / June 2004

Tip: Looking for answers? Try searching our database.

Delphi VarArrayCreate() to C#

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bill Gaddis - 04 Jun 2004 16:01 GMT
I am needing to know how to translate the VarArrayCreate method in Delphi into c#.  Let me step back and explain the scenario

I am in the process of converting a Delphi program over to C#.  The ActiveX component is Tidestone's F1Book spreadsheet that was developed prior to the .Net craze. And, of course is no longer available for windows.  The .Net environment created a COM wrapper around this ActiveX component so that the method calls are very similar, but not quite..

This one method that used a variant parameter now takes an object parameter

Here is the Delphi code..

procedure tAmortizationReport.CreateSummary
va
 VA: Variant
begi
 with fSS d
 begi
   VA := VarArrayCreate([0,1], varSmallInt)
   VA[0] := -3;
   VA[1] := 4;
   SORT(5, 1, 100, 10, True, VA)
 end
 ..
end

Where the SORT method has this variant parameter, and in this case, a variant array

The .NET translation for the SORT method looks like this...

Sort(int row1, int col1, int row2, int col2, bool rowSort, object Keys

I used the following assignment that I thought closely resembled the VarArrayCreate method in Delphi

object[] colstoSort = new object[2] {1,2}

I have tried many different types of assignments to the object Keys parameter, but each returns the following error..

************** Exception Text *************
System.Runtime.InteropServices.COMException (0x800A4E22): Invalid argument
  at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData
  at TTF160.IF1Book.Sort(Int32 nR1, Int32 nC1, Int32 nR2, Int32 nC2, Boolean bSortByRows, Object Keys

Can anyone fill me in as to what I am doing wrong

Also, is there another component that I may use instead of Tidestones?  I need to use one that allows the spreadsheet to be owned by the form.  I don't know how to do this with Excel
Mattias Sj?gren - 06 Jun 2004 00:20 GMT
Bill,

Have you tried

object colstoSort = new short[] {1,2};

Mattias

Signature

Mattias Sjögren [MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Bill Gaddis - 07 Jun 2004 00:32 GMT
Perfect....thank you very much

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.