|
-
Dec 2nd, 2003, 03:16 AM
#1
Thread Starter
Lively Member
Is this possible with Overloading ?
I want to overload this function thrice..
The first parameter (SourceString) is always passed.
The next two parameters...
Sometimes both can be passed or only and any one can be passed.
When all both (Starts_After and Ends_Before) are passed.
Public Overloads Function fnExtract(
ByVal SourceString As String, _
ByVal Starts_After As String, _
ByVal Ends_Before As String) As String
When only second (Starts_After) is passed
Public Overloads Function fnExtract(
ByVal SourceString As String, _
ByVal Starts_After As String) As String
When only last (Ends_Before) is passed
Public Overloads Function fnExtract(
ByVal SourceString As String, _
ByVal Ends_Before As String) As String
Now this is wrong.. because the last two are identical.
I also donot want to use Optional Parameters.
So how do I tackle it.
-
Dec 2nd, 2003, 10:05 PM
#2
PowerPoster
Public Overloads Function fnExtract(
ByVal SourceString As String, _
ByVal Starts_After As String, _
ByVal Ends_Before As String) As String
Just have the one. You can't do what you are trying because you won't use optional parameters, and you have the same function signature the other way.
You should look for null (nothing, empty string) being passed in as the start or end and act accordingly.
-
Dec 3rd, 2003, 07:44 AM
#3
Fanatic Member
Or you could change the method to only accept a StringDictionary (Key / Value pairs), then you can get the items from it. You would still have to check for nothing or the empty string.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|