?
Solved

How to get a method "out" parameter values from Vbscript

Posted on 2003-03-19
9
Medium Priority
?
847 Views
Last Modified: 2008-02-01
I have a .NET class that I register (with regasm) as a
COM object. It has a method that returns to caller an array of ints. I
create that object from Vbscript and try to get the returned array,
but get a runtime error.

The .NET class (simplified):

public class myclass {
   public myclass{
     ...
   }
   public int link(string ip){
     // no problem calling this method
     ...
     return 1;
   }
   public int getcounter(int param1, out ulong[] myarray){
     // can't call this method
     myarray = new ulong[2];
     myarray[0] = 0;
     myarray[1] = 1;
     return 1;
   }
}

The class is registred with regasm and called from vbscript as follows

'this is test.vbs
dim arr
set myobj = CreateObject("myclass.myclass")
ret = myobj.link("192.168.100.101")
ret = myobj.getcounter(1, arr)

Creation of the object and the call to "link" method works fine. The
call to getcounter throws at vbscript exception 800A0005 "Invalid
procedure call or argument: 'getcounter'"

I guess this has to do with the "out" parameter, but I don't know how
to make this work.

Thanks,
careta
0
Comment
Question by:careta
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
9 Comments
 
LVL 10

Expert Comment

by:smegghead
ID: 8167934
I know VB never had a concept of 'out' variables, so I very much doubt that VBScript would have.

I would just change it to 'ref'

or alternatively (and probably preferably), just call a separate function to return the array

Smg.
0
 

Author Comment

by:careta
ID: 8168155
First, I never had a problem to call an interface's method with "out" parameters from VB.
Second, changing to "ref" doesn't work either.
Third, it looks as a serious limitation to be able to return a single value per method.

careta
0
 
LVL 10

Expert Comment

by:smegghead
ID: 8168217
what happens if you change ulong to int ?? just out of interest. It may be this that's causing the problem.

Smg.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:careta
ID: 8168384
the same...
0
 
LVL 18

Expert Comment

by:testn
ID: 8178890
int is 32-bit and long is 64-bit in C# while
Integer is 16-bit and Long is 32-bit in VB. Therefore, you should use int instead to make VB able to refer to your object.
0
 

Author Comment

by:careta
ID: 8179647
I tried both: long and int, with same results.
I did some browsing in the interop newsgroup and it looks as there is some limitation with "out" or "ref" parameters from a .NET COM object and VB flavors. Is that possible? it's hard to believe, but that's what I see.
0
 
LVL 18

Accepted Solution

by:
testn earned 800 total points
ID: 8180568
Oh, I just noticed that you're using VBScript not VB6. In that case, I think there is no way that you can pass object as an array since VBscript is loosely typed language.

You might try to return your array as an object. Let's try. Might work
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month8 days, 2 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question