Results 1 to 3 of 3

Thread: Is this possible with Overloading ?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2003
    Posts
    110

    Question 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.
    Anis Bombaywala

  2. #2
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    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.

  3. #3
    Fanatic Member VBCrazyCoder's Avatar
    Join Date
    Apr 2003
    Posts
    681
    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
  •  



Click Here to Expand Forum to Full Width