473,326 Members | 2,127 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

How make Guid parameter optional in function?

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
May 24 '07 #1
3 7296
"Ronald S. Cook" <rc***@westinis.comwrote in
news:e6**************@TK2MSFTNGP04.phx.gbl:
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.
May 24 '07 #2
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
"Ronald S. Cook" wrote:
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
May 25 '07 #3
=?Utf-8?B?RGF2aWQgQW50b24=?= <Da********@discussions.microsoft.com>
wrote in news:B7**********************************@microsof t.com:
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.
May 25 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: John T | last post by:
I am trying to make a function that takes an optional parameter that gets passed by reference. Here is the first line of my function definition: function funQueryDatabase($strQuery,...
7
by: JT | last post by:
how can i declare a function that will accept an optional parameter? something like: function newFunc(strValue1, strValue2) --where strValue2 is optional. thanks much.
4
by: PawelF | last post by:
I need to replace string with Guid ready to use: public const string GUID_1 = "CF0003D61F6E4D6AA6B17B18E5057FCD"; like public const Guid ... Is there any chance to do this.
10
by: John Morgan | last post by:
Does anyone know what parameter should be used instead of Date = 0 for the optional parameter in the following function? Public Function dhAge(ByVal dtmBD As Date, Optional ByVal dtmDate As Date...
1
by: Scott M. Lyon | last post by:
I've got a stored procedure that takes a few parameters as input parameters, and one output parameter (a uniqueidentifier). After the stored procedure call, I need to return that output parameter...
1
by: Scott M. Lyon | last post by:
I've got a stored procedure that takes a few parameters as input parameters, and one output parameter (a uniqueidentifier). After the stored procedure call, I need to return that output parameter...
3
by: Wayne Wengert | last post by:
Using VSNET2005. I want to insert some rows into a table. Each row has 2 columns, "memberid" which is a GUID and "Interests" which is a varchar. I created a SQLDataSource with the values to insert...
1
by: KayC | last post by:
Hi I am using Access2002 I have a form with 5 text boxes which are parameters to a function 3 parameters are optional in the function How do I pass the empty textbox values to a optional...
7
by: jamesclose | last post by:
My problem is this (apologies if this is a little long ... hang in there): I can define a function in VB.NET with optional parameters that wraps a SQL procedure: Sub Test(Optional ByVal Arg1...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.