Help: Question about passing user-defined type to a function 
Author Message
 Help: Question about passing user-defined type to a function

Hi:

I would like to know if it is possible to pass a "generic" user-defined type to
a function.

For example, I want to be able to define 2 different datatypes as in:

Type type_a
        ...
End Type

Type type_b
        ...
End Type

Note: The ... in each of these is not the same.

Then, I want to be able to pass type_a and type_b to a function but I can't
find a way to make function parameters accept a generic user-defined type.

What I have right now is:

Function myfunc (SomeType As type_a)
        ...
End Function

*and*

Function myfunc (SomeType As type_b)
        ...
End Function

NOTE: The ... in each of these functions are EXACTLY the same, hence I would
like to make only 1 function and pass type_a and type_b to it.

Any help is appreciated!!

     -Paul



Sat, 11 Oct 1997 03:00:00 GMT  
 Help: Question about passing user-defined type to a function
Ah, you've come across another infamous VB limit: it can't
treat different custom types as a single type (like C can
with its union keyword). Gates, if you're reading this...


The message title was 'C-like Union in VB ?' and may still be
on this newsgroup. Since I replied using my Netscape posting
dialog, I don't have a copy of what I said (whoops).

My reply was to use a handrolled construct known as a parameter
block. You take a string, but write a few routines to let
arguments be put into it, read from it, removed from it, etc.
Then you simply pass these strings to your functions. One of
the parameters in the string can be used to indicate what the
remaining parameters are (i.e., what the structure of the
rest of the string is).

--  
___________________________________



Sat, 11 Oct 1997 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Help with passing user defined types as variables in functions - VB4 32bit

2. Passing a user defined type to a function.

3. Passing User-defined types to public functions?

4. Passing user defined types to functions/procedures

5. Passing User-defined type to a public function?

6. Passing Public user-defined types via Public Functions

7. *Help -- Cannot pass user-defined types as parameters

8. User Control and User Defined Type Passing

9. Need help passing user defined types to ActiveXLL

10. Help passing user defined types

11. Passing Args of User Defined Types - HELP

12. Passing user defined types to a functio and returning Help Please

 

 
Powered by phpBB® Forum Software