473,486 Members | 2,162 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Component Creation

Hi All,

I am creating a component library and I have a function that contains
optional parameters. Here's the skeleton code for the function:

Public Function SearchBook(ByVal page as String, Optional ByVal keyword
As String = Nothing, Optional ByVal categoryID As String = Nothing) As Book

' implementation code omitted

End Function

My gripe is with the optional parameters. Specifically, this function
can be used three ways:

1. use take the page and keyword params (omitting the catagoryID param)
2. use the page and categoryID params (omitting the keyword param)
3. use all three params.

Are there any penalties for ignoring only one of the optional
parameters? Must they both be used (because I don't feel like writing
overloaded functions)if one of them is used? Is the order in which
they're placed an issue?

Thanks,
Roshawn
Nov 21 '05 #1
4 904

"Roshawn Dawson" <ud****@bellsouth.net> wrote
My gripe is with the optional parameters. Specifically, this function
can be used three ways:

1. use take the page and keyword params (omitting the catagoryID param)
2. use the page and categoryID params (omitting the keyword param)
3. use all three params.

Are there any penalties for ignoring only one of the optional
parameters? Must they both be used (because I don't feel like writing
overloaded functions)if one of them is used? Is the order in which
they're placed an issue?


I don't have a link to point to, but my understanding was that even though
you give it optional parameters, the compiler treats it as if all of them are
required. For code that does not use one of the optional parameters, the
compiler will simply add the default value in for the missing parameter.

Is the order an issue? I would think you should try to put the most
common in front, (to making coding easier) but when all are strings,
what could it matter?

Passing in Page as a string seems odd, shouldn't that be a number?

LFS
Nov 21 '05 #2

"Roshawn Dawson" <ud****@bellsouth.net> wrote
My gripe is with the optional parameters. Specifically, this function
can be used three ways:

1. use take the page and keyword params (omitting the catagoryID param)
2. use the page and categoryID params (omitting the keyword param)
3. use all three params.

Are there any penalties for ignoring only one of the optional
parameters? Must they both be used (because I don't feel like writing
overloaded functions)if one of them is used? Is the order in which
they're placed an issue?


I don't have a link to point to, but my understanding was that even though
you give it optional parameters, the compiler treats it as if all of them are
required. For code that does not use one of the optional parameters, the
compiler will simply add the default value in for the missing parameter.

Is the order an issue? I would think you should try to put the most
common in front, (to making coding easier) but when all are strings,
what could it matter?

Passing in Page as a string seems odd, shouldn't that be a number?

LFS
Nov 21 '05 #3
Look into the "overloads" statement.
"Roshawn Dawson" <ud****@bellsouth.net> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi All,

I am creating a component library and I have a function that contains
optional parameters. Here's the skeleton code for the function:

Public Function SearchBook(ByVal page as String, Optional ByVal keyword
As String = Nothing, Optional ByVal categoryID As String = Nothing) As Book

' implementation code omitted

End Function

My gripe is with the optional parameters. Specifically, this function
can be used three ways:

1. use take the page and keyword params (omitting the catagoryID param)
2. use the page and categoryID params (omitting the keyword param)
3. use all three params.

Are there any penalties for ignoring only one of the optional
parameters? Must they both be used (because I don't feel like writing
overloaded functions)if one of them is used? Is the order in which
they're placed an issue?

Thanks,
Roshawn

Nov 21 '05 #4
Look into the "overloads" statement.
"Roshawn Dawson" <ud****@bellsouth.net> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi All,

I am creating a component library and I have a function that contains
optional parameters. Here's the skeleton code for the function:

Public Function SearchBook(ByVal page as String, Optional ByVal keyword
As String = Nothing, Optional ByVal categoryID As String = Nothing) As Book

' implementation code omitted

End Function

My gripe is with the optional parameters. Specifically, this function
can be used three ways:

1. use take the page and keyword params (omitting the catagoryID param)
2. use the page and categoryID params (omitting the keyword param)
3. use all three params.

Are there any penalties for ignoring only one of the optional
parameters? Must they both be used (because I don't feel like writing
overloaded functions)if one of them is used? Is the order in which
they're placed an issue?

Thanks,
Roshawn

Nov 21 '05 #5

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

Similar topics

3
2562
by: Alan | last post by:
Gidday people, I had a bit of a problem this morning. I think I've got it sorted now, but I wonder if anyone can shed some light. I have a plain VBS WHS file that instantiates a component that...
0
2806
by: acharyaks | last post by:
Hi life saver, I am using excel component for the development. The purpose is to connect to excel through the odbc connection string. Then through the connection extract data into a dataset and...
0
968
by: Steven Kilby | last post by:
I have a component (inproc dll) written in VB6. I have a client written in C#. If I compile the component to native code everything works fine. I add the necessary type library for my component...
7
1182
by: Adam Nowotny | last post by:
I'm writing an application that displays some information from database. So far i'm using the axWebBrowser to render the content - this is quite usefull to show formated text, picture, tables,...
2
1735
by: dchadha | last post by:
Hi, I need to convert HTML (online or offline) to PDF in C# application. In addition I want to merge PDF documents also on the fly. I am looking for C# / VB.NET code or a .NET component which...
3
2205
by: Michel Smit | last post by:
I'm running into another problem with my component. I'm trying to use .NET remoting to avoid complex firewall issues. I have a webserver which is the client machine and a database server which...
7
2206
by: Joe | last post by:
Is it possible to have a component which is global to the entire application? I need to have a single component act sort of like a server which components in any of the forms can access. For...
4
1637
by: Mario Vázquez | last post by:
Hi all, I'm trying to build a component which takes advantage of other components. So, when this new component is draged to the form, I would like to insert other components on the designer and...
7
3764
by: Ben | last post by:
Hi We are looking for a component that offers that offers the below for Tiff files: Image clean-up (deskew, despeckle) Printing capabilities from VB The ability to add text to image, e.g....
0
5323
by: bharathreddy | last post by:
In .Net COM+ components are referred to as serviced components, Namespace: System.EnterpriseServices; Advantage of Serviced Components: object pooling, database connection pooling,
0
7100
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6964
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7175
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6842
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
4865
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4559
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3070
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
598
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.