Hi,
I'm doing a few POC tests to prove the viability of .Net in anexisting application for a client. Essentially the existing appuses VBA to do various tasks in Excel. I am in the process ofmoving some of the modules out and into various C# classes,providing COM interfaces to allow existing code to use the new"functions" with the minimal amount of change to the clientcode. Up until now I haven't ahd too many headaches,unfortunately that is until I tried to replace a VBA method thatused the ParamArray "type":
Public Function CallProcedure(pstrProcedure As String, ParamArrayparrAllArguments()) As Variant
Obviously my first thought was to write the corresponding C#code:
public object CallProcedure(string Procedure, params object[]AllArguments)
Compiling and then looking at the object in the object browser ofVBA, the C# function looks fine - the definition is exactly asthe original (shown previously). However when I try to actuallyuse it, all hell breaks loose - slight exaggeration I know, butit has caused me quite a headache. VBA throws an error messageas follows:
"Run-time error '450':
Wrong number of arguments or invalid property assignment"
I used the function in the following manner:
varResult = oleDBObj.CallProcedure("STRING1", "STRING2","STRING3", "STRING4")
compared with the original method call:
varResult = CallProcedure("STRING1", "STRING2", "STRING3","STRING4")
You will note there is very little difference (as was myintention) I need to resolve this issue ASAP as obviously if theclient sees that there are issues such as this, they will balkat the idea of .Net
Any help would be GREATLY appreciated...
Kind regards,
James Phillips
-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)
<Id>4vs6qiSrPE+/qY0qSVPOgw==</Id>