How make Guid parameter optional in function?

R

Ronald S. Cook

I have a function in which I'm trying to make the parameter optional.
However, when I put Optional in front of ByVal below I get the error
"optional parameters cannot have structure types".

Public Function SelectPenType(ByVal PenTypeID As Guid) As DataSet Implements
IPen.SelectPenType

Any idea how I should be doing this?

Thanks,
Ron
 
G

Guest

I have a function in which I'm trying to make the parameter optional.
However, when I put Optional in front of ByVal below I get the error
"optional parameters cannot have structure types".

Public Function SelectPenType(ByVal PenTypeID As Guid) As DataSet
Implements IPen.SelectPenType

Any idea how I should be doing this?


I would create an overloaded version of the function. i.e.

Public Function SelectPenType() As DataSet Implements IPen.SelectPenType
SelectPenType(Nothing)
End Fucntion

Also take a look at the Nullable types or you can njust pass in a fixed
value, i.e. GUID.empty to represent no parameter.
 
G

Guest

That's a very confusing error message. There is no problem having optional
parameter types for most structure types, so the message should have
indicated why "Guid" was treated differently than other structure types such
as double, DateTime, decimal, etc.
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
C++ to C# Converter: converts C++ to C#
Instant C++: converts C# or VB to C++/CLI
 
G

Guest

so the message should have
indicated why "Guid" was treated differently than other structure
types such as double, DateTime, decimal, etc.

I think it's because those are called "Base Types". I don't think GUID is a
base type.
 

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