overloading

D

Dave

I have a function 'Private MyFunc(ByVal dbS as String) As Boolean' where dbS
is a database value determined by the database reader method.

I was having some difficulty when dbS is null, so I decided to create an
overloaded function: 'Private Overloads MyFunc(ByVal dbS as DBNull) As
Boolean'. I added the Overloads keyword to the original also, of course.

This resulted in the run-time error "Public member 'MyFunc' on type
'MyClass' not found."

This did not make sense, but on a whim, I changed the Private declarations
to Public, and it worked fine. Can anyboday explain this? Why does
overloading change the requirements of Private/Public?

Thanks,

Dave
 
L

Landley

This cannot be erroring in the method's signature. If the value of the
argument is null, this can be passed into the method. It just needs
checking before it is used.

Landers
 
D

Dave

Thank you, but I'm not sure I understand your answer completely.

In MyFunc(), I did a Select Case for IsDBNull(), but it still didn't like
getting a null value when it expected a string, and it crashed. I suppose I
could do a Try-Catch for this specific exception, but I'm now mainly curious
about my original solution.

Do you have any insights on why you have to change Private to Public on an
overloaded function?

Thanks,

Dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top