Public Method in a class calling a private method in same class yields ByRef error 
Author Message
 Public Method in a class calling a private method in same class yields ByRef error

OK,
I have some code in a public method calling a private worker method all in a
public multiuse class of an ActiveX DLL project.  The problem is that it
wont compile because I get this error...

    Compile Error
    ByRef  argument type mismatch

The code in the public method calls the private method like this...

    Dim part1, part2 As Long
        ...
    SplitZip part1, part2, entireZipCode

And the function signature for the private method is as so.

    Private Function FormatZip(ByVal part1 As Long, ByVal part2 As Long) As
String
        ...
    End Function

The types are the exact same!  Why is VB throwing this error!

Thanks for any help.

Regards,

Bob Hansen



Mon, 19 Jan 2004 03:40:13 GMT  
 Public Method in a class calling a private method in same class yields ByRef error
part1 may not be what you think.  By doing a Dim the way you did part1 may
be a variant not a long
if you set a break point on the the splitsip function then hold the mouse
pointer over part1 you will see the popup and it will contain the word
empty.  Subsequently if you do the same to part2 it will contain 0.

Also what are you doing between the Splitz and the FormatZip function?

Steven Szelei


Quote:
> OK,
> I have some code in a public method calling a private worker method all in
a
> public multiuse class of an ActiveX DLL project.  The problem is that it
> wont compile because I get this error...

>     Compile Error
>     ByRef  argument type mismatch

> The code in the public method calls the private method like this...

>     Dim part1, part2 As Long
>         ...
>     SplitZip part1, part2, entireZipCode

> And the function signature for the private method is as so.

>     Private Function FormatZip(ByVal part1 As Long, ByVal part2 As Long)
As
> String
>         ...
>     End Function

> The types are the exact same!  Why is VB throwing this error!

> Thanks for any help.

> Regards,

> Bob Hansen



Mon, 19 Jan 2004 05:14:44 GMT  
 Public Method in a class calling a private method in same class yields ByRef error
Thank you, that worked.  Why does it convert that parameter to a variant?  I
thought you could do multiple declarations in VB like that.

Cheers,

Bob Hansen


Quote:
> part1 may not be what you think.  By doing a Dim the way you did part1 may
> be a variant not a long
> if you set a break point on the the splitsip function then hold the mouse
> pointer over part1 you will see the popup and it will contain the word
> empty.  Subsequently if you do the same to part2 it will contain 0.

> Also what are you doing between the Splitz and the FormatZip function?

> Steven Szelei



> > OK,
> > I have some code in a public method calling a private worker method all
in
> a
> > public multiuse class of an ActiveX DLL project.  The problem is that it
> > wont compile because I get this error...

> >     Compile Error
> >     ByRef  argument type mismatch

> > The code in the public method calls the private method like this...

> >     Dim part1, part2 As Long
> >         ...
> >     SplitZip part1, part2, entireZipCode

> > And the function signature for the private method is as so.

> >     Private Function FormatZip(ByVal part1 As Long, ByVal part2 As Long)
> As
> > String
> >         ...
> >     End Function

> > The types are the exact same!  Why is VB throwing this error!

> > Thanks for any help.

> > Regards,

> > Bob Hansen



Mon, 19 Jan 2004 21:34:02 GMT  
 Public Method in a class calling a private method in same class yields ByRef error
Nope, VB does not support that type of declaration.  At least not in this
version. <g>  VB.NET will.

Thank You,
Dale Roberson
Microsoft Developer Support



Mon, 19 Jan 2004 22:25:33 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Using a UDT in a Class method, how to make a class module public

2. How to call one VB class module method from another class in an ActiveX dll

3. Access to private members from class method

4. Can you hide a public method of a base class

5. Passing UDTs to public class methods

6. Getting public methods of objects and classes

7. Remove Interface Methods from class methods

8. Classes - Using Classes as method arguments???

9. Calling a Class Module Method

10. problem calling class methods (crosspost)

11. Public or Private instance of class ?

12. Calling methods across classes within ActiveX-Dll

 

 
Powered by phpBB® Forum Software