Arguments in a VB function 
Author Message
 Arguments in a VB function

Hi.

I have a function in which I need to output two different values. Can I have two
output parameters in a VB function? If so, how? If not, is there a workaround?

Thanks.

Vinay



Sat, 22 Nov 2003 19:31:45 GMT  
 Arguments in a VB function
Hi,

A function is normally considered to return just one "value", but this "value" can
be an array, a collection or a UDT (some restrictions).

In addition, if you pass an argument ByRef to a Function (or a Sub), its value can
be set by the function and be available to the calling routine.  Thus you can do:

Private Function xyz(ByRef z as Long) as Long
    xyz  =  1234
    z = 5678
End Function

'To call:
Dim x as Long, y as Long
x  =  xyz(y)
Debug.Print x ' gives 1234
Debug.Print y ' gives 5678

Regards,

John..............

John..................

Quote:

> Hi.

> I have a function in which I need to output two different values. Can I have two
> output parameters in a VB function? If so, how? If not, is there a workaround?

> Thanks.

> Vinay



Sat, 22 Nov 2003 20:11:42 GMT  
 Arguments in a VB function
You can use this approach (just general outline):

1. Declare your function as string.
2. Compose an xml from your output parameters (any number of them).
    <output><par1>val1</par1>...<parN>valN</parN></output>
3. Assign resulting xml to your function.

--
Mikhail Berlyant
Brainbench MVP for Visual Basic
http://www.brainbench.com
Distribution Systems Lead, Data Systems
http://www.launch.com


Hi.

I have a function in which I need to output two different values. Can I have
two
output parameters in a VB function? If so, how? If not, is there a
workaround?

Thanks.

Vinay



Sun, 23 Nov 2003 00:49:59 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. problems with C/C++ DLL passing arguments to VB Callback Function

2. VB functions for Excel: dimension of argument matrices?

3. VB calling a C DLL function that takes a double CHAR pointer as argument

4. Varibale number of arguments in VB function...

5. Function executes only when all arguments are non-empty

6. refering to control on form in global function (form as argument)

7. Passing Table Name as Function Argument

8. Argument Not Optional: ac97, calling a function

9. Function in field Control Source gets bad arguments?

10. const as argument in a function ??

11. Passing Null Arguments to a function?

12. Passing query name as argument in function call

 

 
Powered by phpBB® Forum Software